Commit Graph

82 Commits

Author SHA1 Message Date
David Malcolm c3388e6249 Implement -Wmisleading-indentation
gcc/ChangeLog:
	* doc/invoke.texi (Warning Options): Add -Wmisleading-indentation.
	(-Wmisleading-indentation): New option.
	* Makefile.in (C_COMMON_OBJS): Add c-family/c-indentation.o.

gcc/c-family/ChangeLog:
	* c-common.h (warn_for_misleading_indentation): New prototype.
	* c-indentation.c: New file.
	* c.opt (Wmisleading-indentation): New option.

gcc/c/ChangeLog:
	* c-parser.c (c_parser_if_body): Add param "if_loc", use it
	to add a call to warn_for_misleading_indentation.
	(c_parser_else_body): Likewise, adding param "else_loc".
	(c_parser_if_statement): Check for misleading indentation.
	(c_parser_while_statement): Likewise.
	(c_parser_for_statement): Likewise.

gcc/cp/ChangeLog:
	* parser.c (cp_parser_selection_statement): Add location and
	guard_kind arguments to calls to
	cp_parser_implicitly_scoped_statement.
	(cp_parser_iteration_statement): Likewise for calls to
	cp_parser_already_scoped_statement.
	(cp_parser_implicitly_scoped_statement): Add "guard_loc" and
	"guard_kind" params; use them to warn for misleading
	indentation.
	(cp_parser_already_scoped_statement): Likewise.

gcc/testsuite/ChangeLog:
	* c-c++-common/Wmisleading-indentation.c: New testcase.
	* c-c++-common/Wmisleading-indentation-2.c: New testcase.
	* c-c++-common/Wmisleading-indentation-2.md: New file.

libcpp/ChangeLog:
	* directives.c (do_line): Set seen_line_directive on line_table.
	(do_linemarker): Likewise.
	* include/line-map.h (struct line_maps): Add new field
	"seen_line_directive".

From-SVN: r223098
2015-05-12 20:57:38 +00:00
Jakub Jelinek fb136e35c7 re PR preprocessor/65238 (__has_attribute is not handled properly with -traditional-cpp.)
PR preprocessor/65238
	* internal.h (_cpp_scan_out_logical_line): Add third argument.
	* directives.c (prepare_directive_trad): Pass false to it.
	* traditional.c (_cpp_read_logical_line_trad,
	_cpp_create_trad_definition): Likewise.
	(struct fun_macro): Add paramc field.
	(fun_like_macro): New function.
	(maybe_start_funlike): Handle NODE_BUILTIN macros.  Initialize
	macro->paramc field.
	(save_argument): Use macro->paramc instead of
	macro->node->value.macro->paramc.
	(push_replacement_text): Formatting fix.
	(recursive_macro): Use fun_like_macro helper.
	(_cpp_scan_out_logical_line): Likewise.  Add BUILTIN_MACRO_ARG
	argument.  Initialize fmacro.paramc field.  Handle builtin
	function-like macros.

	* c-c++-common/cpp/pr65238-1.c: New test.
	* gcc.dg/cpp/pr65238-2.c: New test.
	* gcc.dg/cpp/trad/pr65238-3.c: New test.
	* gcc.dg/cpp/trad/pr65238-4.c: New test.

From-SVN: r221587
2015-03-23 09:02:39 +01:00
Marek Polacek 10ef8f287e re PR preprocessor/60570 (expression in 'elif' directive mis-diagnosed as error when group will be skipped)
DR#412
	PR preprocessor/60570
	* directives.c (do_elif): Don't evaluate #elif conditionals
	when they don't need to be.

	* gcc.dg/cpp/pr36320.c: Turn dg-error into dg-bogus.
	* gcc.dg/cpp/pr60570.c: New test.

From-SVN: r220035
2015-01-23 11:57:43 +00:00
Jakub Jelinek 5624e564d2 Update copyright years.
From-SVN: r219188
2015-01-05 13:33:28 +01:00
Jakub Jelinek 1f8d3e84ee re PR preprocessor/63831 (r217292 causes segfaults with -MM)
PR preprocessor/63831
	* c-cppbuiltin.c (c_cpp_builtins): Don't define __has_attribute
	and __has_cpp_attribute here.
	* c-ppoutput.c (init_pp_output): Set cb->has_attribute to
	c_common_has_attribute.
	* c-common.h (c_common_has_attribute): New prototype.
	* c-lex.c (init_c_lex): Set cb->has_attribute to
	c_common_has_attribute instead of cb_has_attribute.
	(get_token_no_padding): New function.
	(cb_has_attribute): Renamed to ...
	(c_common_has_attribute): ... this.  No longer static.  Use
	get_token_no_padding, require ()s, don't build TREE_LIST
	unnecessarily, fix up formatting, adjust diagnostics, call
	init_attributes.

	* directives.c (lex_macro_node): Remove __has_attribute__ handling.
	* internal.h (struct spec_node): Remove n__has_attribute__ field.
	(struct lexer_state): Remove in__has_attribute__ field.
	* macro.c (_cpp_builtin_macro_text): Handle BT_HAS_ATTRIBUTE.
	* identifiers.c (_cpp_init_hashtable): Remove __has_attribute__
	handling.
	* init.c (builtin_array): Add __has_attribute and __has_cpp_attribute.
	(cpp_init_special_builtins): Don't initialize __has_attribute
	or __has_cpp_attribute if CLK_ASM or pfile->cb.has_attribute is NULL.
	* traditional.c (enum ls): Remove ls_has_attribute,
	ls_has_attribute_close.
	(_cpp_scan_out_logical_line): Remove __has_attribute__ handling.
	* include/cpplib.h (enum cpp_builtin_type): Add BT_HAS_ATTRIBUTE.
	* pch.c (cpp_read_state): Remove __has_attribute__ handling.
	* expr.c (eval_token): Likewise.
	(parse_has_attribute): Removed.

	* c-c++-common/cpp/pr63831-1.c: New test.
	* c-c++-common/cpp/pr63831-2.c: New test.

From-SVN: r218948
2014-12-19 13:20:58 +01:00
Uros Bizjak 01ca36af91 xvasprintf.c: New file.
* xvasprintf.c: New file.
	* vprintf-support.h: Likewise.
	* vprintf-support.c: Likewise.
	* Makefile.in (CFILES): Add vprintf-support.c, xvasprintf.c.
	(REQUIRED_OFILES): Add vprintf-support.$(objext), xvasprintf.$(objext).
	(vprintf-support.$(objext), xvasprintf.$(objext)): New targets.
	(vasprintf.$(objext)): Depend on $(srcdir)/vprintf-support.h.
	* functions.texi: Regenerate.
	* vasprintf.c (int_vasprintf): Use libiberty_vprintf_buffer_size.

include/ChangeLog:

	* libiberty.h (xvasprintf): Declare.

libcpp/ChangeLog:

	* directives.c (cpp_define_formatted): Use xvasprintf.


Co-Authored-By: Ben Elliston <bje@au.ibm.com>
Co-Authored-By: Manuel López-Ibáñez <manu@gcc.gnu.org>

From-SVN: r218618
2014-12-11 09:15:37 +01:00
Edward Smith-Rowland 42fd12b1e7 cpplib.h (cpp_callbacks): Add has_attribute.
libcpp:

2014-11-10  Edward Smith-Rowland  <3dw4rd@verizon.net>

	* include/cpplib.h (cpp_callbacks): Add has_attribute.
	* internal.h (lexer_state): Add in__has_attribute__.
	* directives.c (lex_macro_node): Prevent use of __has_attribute__
	as a macro.
	* expr.c (parse_has_attribute): New function; (eval_token): Look for
	__has_attribute__ and route to parse_has_attribute.
	* identifiers.c (_cpp_init_hashtable): Initialize n__has_attribute__.
	* pch.c (cpp_read_state): Initialize n__has_attribute__.
	* traditional.c (enum ls): Add ls_has_attribute, ls_has_attribute_close;
	(_cpp_scan_out_logical_line): Attend to __has_attribute__.


gcc/c-family:

2014-11-10  Edward Smith-Rowland  <3dw4rd@verizon.net>

	* c-cppbuiltin.c (__has_attribute, __has_cpp_attribute): New macros;
	(__cpp_rtti, __cpp_exceptions): New macros for C++98;
	(__cpp_range_based_for, __cpp_initializer_lists,
	__cpp_delegating_constructors, __cpp_nsdmi,
	__cpp_inheriting_constructors, __cpp_ref_qualifiers): New macros
	for C++11; (__cpp_attribute_deprecated): Remove in favor of
	__has_cpp_attribute.
	* c-lex.c (cb_has_attribute): New callback CPP function;
	(init_c_lex): Set has_attribute callback.


gcc/testsuite:

2014-11-10  Edward Smith-Rowland  <3dw4rd@verizon.net>

	* g++.dg/cpp1y/feat-cxx11.C: Test new feature macros for C++98
	and C++11; Test existence of __has_cpp_attribute;  Test C++11
	attributes.
	* g++.dg/cpp1y/feat-cxx11-neg.C: Ditto.
	* g++.dg/cpp1y/feat-cxx14.C: Ditto and test for C++14 attributes.
	* g++.dg/cpp1y/feat-cxx98.C: Test new feature macros for C++98.
	* g++.dg/cpp1y/feat-cxx98-neg.C: Ditto.
	* g++.dg/cpp1y/feat-neg.C: Test that __cpp_rtti, _cpp_exceptions
	will be undefined for -fno-rtti -fno-exceptions.

From-SVN: r217292
2014-11-10 15:53:12 +00:00
Edward Smith-Rowland a15f7cb8b8 Implement SD-6: SG10 Feature Test Recommendations
2014-10-01  Edward Smith-Rowland  <3dw4rd@verizon.net>

	Implement SD-6: SG10 Feature Test Recommendations
	* internal.h (lexer_state, spec_nodes): Add in__has_include__.
	* directives.c: Support __has_include__ builtin.
	* expr.c (parse_has_include): New function to parse __has_include__
	builtin; (eval_token()): Use it.
	* files.c (_cpp_has_header()): New funtion to look for header;
	(open_file_failed()): Not an error to not find a header file for
	__has_include__.
	* identifiers.c (_cpp_init_hashtable()): Add entry for __has_include__.
	* pch.c (cpp_read_state): Lookup __has_include__.
	* traditional.c (enum ls, _cpp_scan_out_logical_line()): Walk through
	__has_include__ statements.

2014-10-01  Edward Smith-Rowland  <3dw4rd@verizon.net>

	Implement SD-6: SG10 Feature Test Recommendations
	* c-cppbuiltin.c (c_cpp_builtins()): Define language feature
	macros and the __has_header macro.

2014-10-01  Edward Smith-Rowland  <3dw4rd@verizon.net>

	Implement SD-6: SG10 Feature Test Recommendations
	* include/bits/basic_string.h: Add __cpp_lib feature test macro.
	* include/bits/stl_algobase.h: Ditto.
	* include/bits/stl_function.h: Ditto.
	* include/bits/unique_ptr.h: Ditto.
	* include/std/chrono: Ditto.
	* include/std/complex: Ditto.
	* include/std/iomanip: Ditto.
	* include/std/shared_mutex: Ditto.
	* include/std/tuple: Ditto.
	* include/std/type_traits: Ditto.
	* include/std/utility: Ditto.
	* testsuite/experimental/feat-cxx14.cc: New.
	* testsuite/experimental/feat-lib-fund.cc: New.
	* testsuite/20_util/declval/requirements/1_neg.cc: Adjust.
	* testsuite/20_util/duration/literals/range.cc: Adjust.
	* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Adjust.
	* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Adjust.
	* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Adjust.
	* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust.
	* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Adjust.
	* testsuite/23_containers/array/tuple_interface/get_neg.cc: Adjust.
	* testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc:
	Adjust.

2014-10-01  Edward Smith-Rowland  <3dw4rd@verizon.net>

	Implement SD-6: SG10 Feature Test Recommendations
	* g++.dg/cpp1y/feat-cxx11-neg.C: New.
	* g++.dg/cpp1y/feat-cxx11.C: New.
	* g++.dg/cpp1y/feat-cxx14.C: New.
	* g++.dg/cpp1y/feat-cxx98.C: New.
	* g++.dg/cpp1y/feat-cxx98-neg.C: New.
	* g++.dg/cpp1y/phoobhar.h: New.
	* g++.dg/cpp1y/testinc/phoobhar.h: New.

From-SVN: r215752
2014-10-01 11:49:23 +00:00
Manuel López-Ibáñez 81b5d104e9 directives.c (check_eol_1): New.
libcpp/ChangeLog:

2014-08-29  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* directives.c (check_eol_1): New.
	(check_eol_endif_labels): New.
	(check_eol): Call check_eol_1.
	(do_else,do_endif): Call check_eol_endif_labels.

gcc/c-family/ChangeLog:

2014-08-29  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* c.opt (Wbuiltin-macro-redefined,Wdeprecated,Wendif-labels,
	Winvalid-pch,Wliteral-suffix,Wmissing-include-dirs,Wtrigraphs,
	Wundef): Use CPP, Var and Init.
	* c-opts.c (c_common_handle_option): Do not handle the above flags here.

From-SVN: r214735
2014-08-29 16:06:19 +00:00
Manuel López-Ibáñez b753b37bd6 macro.c (warn_of_redefinition): Suppress warnings for builtins that lack the NODE_WARN flag...
libcpp/ChangeLog:

2014-08-29  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* macro.c (warn_of_redefinition): Suppress warnings for builtins
	that lack the NODE_WARN flag, unless Wbuiltin-macro-redefined.
	(_cpp_create_definition): Use Wbuiltin-macro-redefined for
	builtins that lack the NODE_WARN flag.
	* directives.c (do_undef): Likewise.
	* init.c (cpp_init_special_builtins): Do not change flags
	depending on Wbuiltin-macro-redefined.


gcc/c-family/ChangeLog:

2014-08-29  Manuel López-Ibáñez  <manu@gcc.gnu.org>

	* c.opt (Wbuiltin-macro-redefined): Use CPP, Var and Init.
	* c-opts.c (c_common_handle_option): Do not handle here.

From-SVN: r214730
2014-08-29 15:28:45 +00:00
Richard Sandiford 35c3d610e3 Update copyright years in libcpp/
From-SVN: r206293
2014-01-02 22:24:45 +00:00
Jakub Jelinek 28937f1196 re PR middle-end/56461 (GCC is leaking lots of memory)
PR middle-end/56461
	* internal.h (struct cpp_buffer): Add to_free field.
	(_cpp_pop_file_buffer): Add third argument.
	* files.c (_cpp_stack_file): Set buffer->to_free.
	(_cpp_pop_file_buffer): Add to_free argument.  Free to_free
	if non-NULL, and if equal to file->buffer_start, also clear
	file->buffer{,_start,_valid}.
	* directives.c (_cpp_pop_buffer): Pass buffer->to_free
	to _cpp_pop_file_buffer.

From-SVN: r196497
2013-03-06 17:18:40 +01:00
Richard Sandiford 500f3ed906 Update copyright years in libcpp.
From-SVN: r195162
2013-01-14 18:13:59 +00:00
Florian Weimer f591bd8f50 Implement #pragma GCC warning/error
2012-10-04  Florian Weimer  <fweimer@redhat.com>

	* doc/cpp.texi (Pragmas): Document #pragma GCC warning, #pragma
	GCC error.

2012-10-04  Florian Weimer  <fweimer@redhat.com>

	* c-c++-common/cpp/diagnostic-pragma-1.c: New testcase.

2012-10-04  Florian Weimer  <fweimer@redhat.com>

	* directives.c (do_pragma_warning_or_error): New.
	(do_pragma_warning): New.
	(do_pragma_error): New.
	(_cpp_init_internal_pragmas): Register new pragmas.

From-SVN: r192084
2012-10-04 17:33:11 +02:00
Dodji Seketeli f3d25c6570 PR preprocessor/53469 - argument tokens of _Pragma miss virtual location
Consider this short test snippet:

-------------------------8-------------------
    #define STRINGIFY(x) #x
    #define TEST(x) \
      _Pragma(STRINGIFY(GCC diagnostic ignored "-Wunused-local-typedefs")) \
      typedef int myint;

    void bar ()
    {
      TEST(myint)
    }
-------------------------8-------------------

The _Pragma is effectively ignored, and compiling with
-Wunused-local-typedefs warns on the local typedef, even though the
pragma should have prevented the warning to be emitted.

This is because when the preprocessor sees the _Pragma operator and
then goes to handle the first token ('GCC' here) that makes up its
operands, it retains the spelling location of that token, not its
virtual location.

Later when diagnostic_report_diagnostic is called to emit the warning
(or ignore it because of the pragma), it compares the location of the
first operand of the pragma with the location of the unused location,
(by calling linemap_location_before_p) and that comparison fails
because in this case, both locations should be virtual.

This patch fixes the issue by teaching the pragma handling to use
virtual locations.

Bootstrapped and tested on x86_64-unknown-linux-gnu against trunk.

libcpp/

	PR preprocessor/53469
	* directives.c (do_pragma): Use the virtual location for the
	pragma token, instead of its spelling location.

gcc/testsuite/

	PR preprocessor/53469
	* gcc.dg/cpp/_Pragma7.c: New test case.

From-SVN: r190714
2012-08-27 17:41:38 +02:00
Joseph Myers 7d9641ccfa directives.c: Fix typos.
* directives.c: Fix typos.
	* include/line-map.h: Fix typos.
	* line-map.c: Fix typos.
	* macro.c: Fix typos.

From-SVN: r187966
2012-05-29 15:53:50 +01:00
Dodji Seketeli 828a7f76c7 PR preprocessor/53229 - Fix diagnostics location when pasting tokens
As stated in the audit trail of this problem report, consider this
test case:

    $ cat test.c
	 1	struct x {
	 2	  int i;
	 3	};
	 4	struct x x;
	 5
	 6	#define TEST(X) x.##X
	 7
	 8	void foo (void)
	 9	{
	10	  TEST(i) = 0;
	11	}
    $

    $ cc1 -quiet test.c
    test.c: In function 'foo':
    test.c:10:1: error: pasting "." and "i" does not give a valid preprocessing token
       TEST(i) = 0;
     ^
    $

So, when pasting tokens, the error diagnostic uses the global and
imprecise input_location variable, leading to an imprecise output.

To properly fix this, I think libcpp should keep the token of the
pasting operator '##', instead of representing it with flag on the LHS
operand's token.  That way, it could use its location.  Doing that
would be quite intrusive though.  So this patch just uses the location
of the LHS of the pasting operator, for now.  It's IMHO better than
the current situation.

The patch makes paste_tokens take a location parameter that is used in
the diagnostics.  This change can still be useful later when we can
use the location of the pasting operator, because paste_tokens will
just be passed the new, more precise location.

Incidentally, it appeared that when getting tokens from within
preprocessor directives (like what is done in gcc.dg/cpp/paste12.c),
with -ftrack-macro-expansion disabled, the location of the expansion
point of macros was being lost because
cpp_reader::set_invocation_location wasn't being properly set.  It's
because when cpp_get_token_1 calls enter_macro_context, there is a
little period of time between the beginning of that later function and
when the macro is really pushed (and thus when the macro is really
expanded) where we wrongly consider that we are not expanding the
macro because macro_of_context is still NULL.  In that period of time,
in the occurrences of indirect recursive calls to cpp_get_token_1,
this later function wrongly sets cpp_reader::invocation_location
because cpp_reader::set_invocation_location is not being properly set.

To avoid that confusion the patch does away with
cpp_reader::set_invocation_location and introduces a new flag
cpp_reader::about_to_expand_macro_p that is set in the small time
interval exposed earlier.  A new in_macro_expansion_p is introduced as
well, so that cpp_get_token_1 can now accurately detect when we are in
the process of expanding a macro, and thus correctly collect the
location of the expansion point.

People seem to like screenshots.

Thus, after the patch, we now have:

    $ cc1 -quiet test.c
    test.c: In function 'foo':
    test.c:6:18: error: pasting "." and "i" does not give a valid preprocessing token
     #define TEST(X) x.##X
		      ^
    test.c:10:3: note: in expansion of macro 'TEST'
       TEST(i) = 0;
       ^
    $

Bootstrapped and tested on x86_64-unknown-linux-gnu against trunk.

libcpp/

	PR preprocessor/53229
	* internal.h (cpp_reader::set_invocation_location): Remove.
	(cpp_reader::about_to_expand_macro_p): New member flag.
	* directives.c (do_pragma):  Remove Kludge as
	pfile->set_invocation_location is no more.
	* macro.c (cpp_get_token_1): Do away with the use of
	cpp_reader::set_invocation_location.  Just collect the macro
	expansion point when we are about to expand the top-most macro.
	Do not override cpp_reader::about_to_expand_macro_p.
	This fixes gcc.dg/cpp/paste12.c by making get_token_no_padding
	properly handle locations of expansion points.
	(cpp_get_token_with_location): Adjust, as
	cpp_reader::set_invocation_location is no more.
	(paste_tokens): Take a virtual location parameter for
	the LHS of the pasting operator.  Use it in diagnostics.  Update
	comments.
	(paste_all_tokens): Tighten the assert.  Propagate the location of
	the expansion point when no virtual locations are available.
	Pass the virtual location to paste_tokens.
	(in_macro_expansion_p): New static function.
	(enter_macro_context): Set the cpp_reader::about_to_expand_macro_p
	flag until we really start expanding the macro.

gcc/testsuite/

	PR preprocessor/53229
	* gcc.dg/cpp/paste6.c: Force to run without
	-ftrack-macro-expansion.
	* gcc.dg/cpp/paste8.c: Likewise.
	* gcc.dg/cpp/paste8-2.c: New test, like paste8.c but run with
	-ftrack-macro-expansion.
	* gcc.dg/cpp/paste12.c: Force to run without
	-ftrack-macro-expansion.
	* gcc.dg/cpp/paste12-2.c: New test, like paste12.c but run with
	-ftrack-macro-expansion.
	* gcc.dg/cpp/paste13.c: Likewise.
	* gcc.dg/cpp/paste14.c: Likewise.
	* gcc.dg/cpp/paste14-2.c: New test, like paste14.c but run with
	-ftrack-macro-expansion.
	* gcc.dg/cpp/paste18.c: New test.

From-SVN: r187945
2012-05-29 11:36:29 +02:00
Dodji Seketeli 3ad64f53da Properly initialize cpp_context in destringize_and_run
destringize_and_run forgets to initialize all the fields of the
cpp_context that it pushes.  Later _cpp_pop_context then gets confused
when it accesses context->tokens_kind via the call to macro_of_context
on context->prev.

The first hunk of this patch is the real obvious fix.  The second hunk
is just an assert that I am adding to err on the safe side.

Tested by on x86_64-unknown-linux-gnu against trunk by running the
test gcc.dg/gomp/macro-4.c under Valgrind, and bootstrapped.

libcpp/

	* directives.c (destringize_and_run): Properly initialize the new
	context.
	* macro.c (_cpp_pop_context): Assert that we shouldn't try to pop
	the initial base context, which has the same life time as the
	current instance of cpp_file.

From-SVN: r187054
2012-05-02 18:55:19 +02:00
Tom Tromey 92582b753e Generate virtual locations for tokens
This second instalment uses the infrastructure of the previous patch
to allocate a macro map for each macro expansion and assign a virtual
location to each token resulting from the expansion.

To date when cpp_get_token comes across a token that happens to be a
macro, the macro expander kicks in, expands the macro, pushes the
resulting tokens onto a "token context" and returns a dummy padding
token. The next call to cpp_get_token goes look into the token context
for the next token [which is going to result from the previous macro
expansion] and returns it.  If the token is a macro, the macro expander
kicks in and you know the story.

This patch piggy-backs on that macro expansion process, so to speak.
First it modifies the macro expander to make it create a macro map for
each macro expansion. It then allocates a virtual location for each
resulting token.  Virtual locations of tokens resulting from macro
expansions are then stored on a special kind of context called an
"expanded tokens context".  In other words, in an expanded tokens
context, there are tokens resulting from macro expansion and their
associated virtual locations.  cpp_get_token_with_location is modified
to return the virtual location of tokens resulting from macro
expansion.  Note that once all tokens from an expanded token context have
been consumed and the context and is freed, the memory used to store the
virtual locations of the tokens held in that context is freed as well.
This helps reducing the overall peak memory consumption.

The client code that was getting macro expansion point location from
cpp_get_token_with_location now gets virtual location from it. Those
virtual locations can in turn be resolved into the different
interesting physical locations thanks to the linemap API exposed by
the previous patch.

Expensive progress. Possibly. So this whole virtual location
allocation business is switched off by default. So by default no
extended token is created. No extended token context is created
either. One has to use -ftrack-macro-expansion to switch this on. This
complicates the code but I believe it can be useful as some of our
friends found out at http://llvm.org/bugs/show_bug.cgi?id=5610

The patch tries to reduce the memory consumption by freeing some token
context memory that was being reused before. I didn't notice any
compilation slow down due to this immediate freeing on my GNU/Linux
system.

As no client code tries to resolve virtual locations to anything but
what was being done before, no new test case has been added.

Co-Authored-By: Dodji Seketeli <dodji@redhat.com>

From-SVN: r180082
2011-10-17 11:59:12 +02:00
Tom Tromey 46427374e1 Linemap infrastructure for virtual locations
This is the first instalment of a set which goal is to track locations
of tokens across macro expansions.  Tom Tromey did the original work
and attached the patch to PR preprocessor/7263.  This opus is a
derivative of that original work.

This patch modifies the linemap module of libcpp to add virtual
locations support.

A virtual location is a mapped location that can resolve to several
different physical locations.  It can always resolve to the spelling
location of a token.  For tokens resulting from macro expansion it can
resolve to:
  - either the location of the expansion point of the macro.
  - or the location of the token in the definition of the
  macro
  - or, if the token is an argument of a function-like macro,
  the location of the use of the matching macro parameter in
  the definition of the macro

The patch creates a new type of line map called a macro map.  For every
single macro expansion, there is a macro map that generates a virtual
location for every single resulting token of the expansion.

The good old type of line map we all know is now called an ordinary
map.  That one still encodes spelling locations as it has always had.

As a result linemap_lookup as been extended to return a macro map when
given a virtual location resulting from a macro expansion.  The layout
of structs line_map has changed to support this new type of map.  So
did the layout of struct line_maps.  Accessor macros have been
introduced to avoid messing with the implementation details of these
datastructures directly.  This helped already as we have been testing
different ways of arranging these datastructure.  Having to constantly
adjust client code that is too tied with the internals of line_map and
line_maps would have been even more painful.

Of course, many new public functions have been added to the linemap
module to handle the resolution of virtual locations.

This patch introduces the infrastructure but no part of the compiler
uses virtual locations yet.

However the client code of the linemap data structures has been
adjusted as per the changes.  E.g, it's not anymore reliable for a
client code to manipulate struct line_map directly if it just wants to
deal with spelling locations, because struct line_map can now
represent a macro map as well.  In that case, it's better to use the
convenient API to resolve the initial (possibly virtual) location to a
spelling location (or to an ordinary map) and use that.

This is the reason why the patch adjusts the Java, Ada and Fortran
front ends.

Also, note that virtual locations are not supposed to be ordered for
relations '<' and '>' anymore.  To test if a virtual location appears
"before" another one, one has to use a new operator exposed by the
line map interface.  The patch updates the only spot (in the
diagnostics module) I have found that was making the assumption that
locations were ordered for these relations.  This is the only change
that introduces a use of the new line map API in this patch, so I am
adding a regression test for it only.

From-SVN: r180081
2011-10-17 11:58:56 +02:00
Dodji Seketeli d0a9fbe16c Use source_location where it is due
libcpp/

	* directives.c (struct if_stack): Use source_location as type
	here.
	* include/cpplib.h (struct cpp_callbacks)<include, define, undef,
	indent, def_pragma, used_define, used_undef>: Properly use
	source_location as parameter type, rather than unsigned int.

From-SVN: r176333
2011-07-15 23:34:02 +02:00
Dodji Seketeli 38fbfaf6fb re PR preprocessor/48532 (Wrong location of namespaced pragma involving macros)
PR preprocessor/48532

libcpp/

	* directives.c (do_pragma): Don't forget the invocation location
	when parsing the pragma name of a namespaced pragma directive.

gcc/testsuite/

	* gcc.dg/cpp/pragma-3.c: New test case.

From-SVN: r174694
2011-06-06 13:33:42 +02:00
Michael Meissner f3c33d9dc8 Make UNSPEC/UNSPECV constants use the enum; Fix 48192; Add test case for 48053
From-SVN: r171247
2011-03-21 16:21:30 +00:00
Eric Botcazou c5a62c6fde re PR preprocessor/39213 (Preprocessor ICE with -m64 and --traditional-cpp)
PR preprocessor/39213
	* directives.c (end_directive): Call _cpp_remove_overlay for deferred
	pragmas as well in traditional mode.

Co-Authored-By: Jakub Jelinek <jakub@redhat.com>

From-SVN: r168490
2011-01-04 23:18:12 +00:00
Kai Tietz d687413849 re PR preprocessor/45362 (Dangling reference about saved cpp_macro for push/pop macro)
2010-09-29  Kai Tietz  <kai.tietz@onevision.com>

	PR preprocessor/45362
	* directives.c (cpp_pop_definition): Make static.
	(do_pragma_push_macro): Reworked to store text
	definition.
	(do_pragma_pop_macro): Add free text definition.
	(cpp_push_definition): Removed.
	* include/cpplib.h (cpp_push_definition): Removed.
	(cpp_pop_definition): Likewise.
	* internal.h (def_pragma_macro): Remove member 'value'
	and add new members 'definition', 'line',
	'syshdr', 'sued' and 'is_undef'.
	* pch.c (_cpp_restore_pushed_macros): Rework to work
	on text definition and store additional macro flags.
	(_cpp_save_pushed_macros): Likewise.

From-SVN: r164729
2010-09-29 20:18:38 +02:00
Joseph Myers e3339d0f33 optc-gen.awk: Generate global_options initializer instead of individual variables.
gcc:
	* optc-gen.awk: Generate global_options initializer instead of
	individual variables.  Add x_ prefix to names of structure
	members.
	* opth-gen.awk: Generate gcc_options structure.  Add x_ prefix to
	names of structure members.
	* doc/tm.texi.in (HARD_FRAME_POINTER_IS_FRAME_POINTER,
	HARD_FRAME_POINTER_IS_ARG_POINTER): Document.
	* doc/tm.texi: Regenerate.
	* alias.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER
	* builtins.c: Use HARD_FRAME_POINTER_IS_ARG_POINTER.
	* c-parser.c (disable_extension_diagnostics,
	restore_extension_diagnostics): Update names of cpp_options
	members.
	* combine.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER
	* common.opt (fcompare-debug-second): Don't use Var.
	* config/alpha/alpha.h (target_flags): Remove.
	* config/arm/arm.h (HARD_FRAME_POINTER_IS_FRAME_POINTER,
	HARD_FRAME_POINTER_IS_ARG_POINTER): Define.
	* config/bfin/bfin.h (target_flags): Remove.
	* config/cris/cris.h (target_flags): Remove.
	* config/i386/i386-c.c (ix86_pragma_target_parse): Update names of
	cl_target_option members.
	* config/i386/i386.c (ix86_force_align_arg_pointer): Remove.
	(ix86_function_specific_print, ix86_valid_target_attribute_tree,
	ix86_can_inline_p): Update names of cl_target_option members.
	* config/i386/i386.h (ix86_isa_flags): Remove.
	* config/lm32/lm32.h (target_flags): Remove.
	* config/mcore/mcore.h (mcore_stack_increment): Remove.
	* config/mcore/mcore.md (addsi3): Remove extern declaration of
	flag_omit_frame_pointer.
	* config/mep/mep.h (target_flags): Remove.
	* config/mips/mips.h (HARD_FRAME_POINTER_IS_FRAME_POINTER,
	HARD_FRAME_POINTER_IS_ARG_POINTER): Define.
	* config/mmix/mmix.h (target_flags): Remove.
	* config/rs6000/rs6000.h (rs6000_xilinx_fpu, flag_pic,
	flag_expensive_optimizations): Remove.
	* config/s390/s390.h (flag_pic): Remove.
	* config/score/score-conv.h (target_flags): Remove.
	* config/sh/sh.h (sh_fixed_range_str): Remove.
	* config/spu/spu.h (target_flags, spu_fixed_range_string): Remove.
	* dbxout.c: Use HARD_FRAME_POINTER_IS_ARG_POINTER
	* df-scan.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER.
	* diagnostic.c (diagnostic_initialize): Update names of
	diagnostic_context members.
	* diagnostic.h (diagnostic_context): Rename inhibit_warnings and
	warn_system_headers.
	(diagnostic_report_warnings_p): Update for new names.
	* dwarf2out.c: Use HARD_FRAME_POINTER_IS_ARG_POINTER
	* emit-rtl.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER and
	HARD_FRAME_POINTER_IS_ARG_POINTER.
	* flags.h (flag_compare_debug): Declare.
	* ira.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER
	* opts.c (flag_compare_debug): Define.
	(common_handle_option): Update names of diagnostic_context
	members.  Handle -fcompare-debug-second.
	(fast_math_flags_struct_set_p): Update names of cl_optimization
	members.
	* reginfo.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER.
	* regrename.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER.
	* reload.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER.
	* reload1.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER.
	* resource.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER.
	* rtl.h (HARD_FRAME_POINTER_IS_FRAME_POINTER,
	HARD_FRAME_POINTER_IS_ARG_POINTER): Define and use.
	* sel-sched.c: Use HARD_FRAME_POINTER_IS_FRAME_POINTER
	* stmt.c: Use HARD_FRAME_POINTER_IS_ARG_POINTER.

gcc/c-family:
	* c-common.c (c_cpp_error): Update names of diagnostic_context
	members.
	* c-cppbuiltin.c (c_cpp_builtins_optimize_pragma): Update names of
	cl_optimization members.
	* c-opts.c (warning_as_error_callback, c_common_handle_option,
	sanitize_cpp_opts, finish_options): Update names of cpp_options
	members.

gcc/fortran:
	* cpp.c (cpp_define_builtins): Update names of gfc_option_t
	members.
	(gfc_cpp_post_options): Update names of cpp_options members.
	(cb_cpp_error): Update names of diagnostic_context members.
	* f95-lang.c (gfc_init_builtin_functions): Update names of
	gfc_option_t members.
	* gfortran.h (gfc_option_t): Rename warn_conversion and
	flag_openmp.
	* intrinsic.c (gfc_convert_type_warn): Update names of
	gfc_option_t members.
	* options.c (gfc_init_options, gfc_post_options, set_Wall,
	gfc_handle_option): Update names of gfc_option_t members.
	* parse.c (next_free, next_fixed): Update names of gfc_option_t
	members.
	* scanner.c (pedantic): Remove extern declaration.
	(skip_free_comments, skip_fixed_comments, include_line): Update
	names of gfc_option_t members.
	* trans-decl.c (gfc_generate_function_code): Update names of
	gfc_option_t members.

gcc/java:
	* java-tree.h (flag_filelist_file, flag_assert, flag_jni,
	flag_force_classes_archive_check, flag_redundant, flag_newer,
	flag_use_divide_subroutine, flag_use_atomic_builtins,
	flag_use_boehm_gc, flag_hash_synchronization,
	flag_check_references, flag_optimize_sci, flag_indirect_classes,
	flag_indirect_dispatch, flag_store_check,
	flag_reduced_reflection): Remove.
	* jcf-dump.c (flag_newer): Remove.
	* jcf.h (quiet_flag): Remove.
	* parse.h (quiet_flag): Remove.

libcpp:
	* include/cpplib.h (cpp_options): Rename warn_deprecated,
	warn_traditional, warn_long_long and pedantic.
	* directives.c (directive_diagnostics, _cpp_handle_directive):
	Update names of cpp_options members.
	* expr.c (cpp_classify_number, eval_token): Update names of
	cpp_options members.
	* init.c (cpp_create_reader, post_options): Update names of
	cpp_options members.
	* internal.h (CPP_PEDANTIC, CPP_WTRADITIONAL): Update names of
	cpp_options members.
	* macro.c (parse_params): Update names of cpp_options members.

From-SVN: r164723
2010-09-29 15:49:14 +01:00
Jakub Jelinek a69d2520e0 re PR preprocessor/45457 (ICE: invalid built-in macro "__DBL_DENORM_MIN__")
PR preprocessor/45457
	* expr.c (parse_defined): Call pfile->cb.user_builtin_macro hook if
	needed.
	* directives.c (do_ifdef, do_ifndef): Likewise.

	* c-c++-common/cpp/pr45457.c: New test.

From-SVN: r163705
2010-09-01 00:47:25 +02:00
Simon Baldwin 87cf065171 diagnostic.h (diagnostic_override_option_index): New macro to set a diagnostic's option_index.
* diagnostic.h (diagnostic_override_option_index): New macro to
	set a diagnostic's option_index.
	* c-tree.h (c_cpp_error): Add warning reason argument.
	* opts.c (_warning_as_error_callback): New.
	(register_warning_as_error_callback): Store callback for
	warnings enabled via enable_warning_as_error.
	(enable_warning_as_error): Call callback, minor code tidy.
	* opts.h (register_warning_as_error_callback): Declare.
	* c-opts.c (warning_as_error_callback): New, set cpp_opts flag in
	response to -Werror=.
	(c_common_init_options): Register warning_as_error_callback in opts.c.
	* common.opt: Add -Wno-cpp option.
	* c-common.c (struct reason_option_codes_t): Map cpp warning
	reason codes to gcc option indexes.
	* (c_option_controlling_cpp_error): New function, lookup the gcc
	option index for a cpp warning reason code.
	* (c_cpp_error): Add warning reason argument, call
	c_option_controlling_cpp_error for diagnostic_override_option_index.
	* doc/invoke.texi: Document -Wno-cpp.

	* cpp.c (cb_cpp_error): Add warning reason argument, set a value
	for diagnostic_override_option_index if CPP_W_WARNING_DIRECTIVE.

	* directives.c (do_diagnostic): Add warning reason argument,
	call appropriate error reporting function for code.
	(directive_diagnostics): Call specific warning functions with
	warning reason where appropriate.
	(do_error, do_warning, do_pragma_dependency): Add warning reason
	argument to do_diagnostic calls.
	* macro.c (_cpp_warn_if_unused_macro, enter_macro_context,
	_cpp_create_definition): Call specific warning functions with
        warning reason where appropriate.
	* Makefile.in: Add new diagnostic functions to gettext translations.
	* include/cpplib.h (struct cpp_callbacks): Add warning reason code
	to error callback.
	(CPP_DL_WARNING, CPP_DL_WARNING_SYSHDR, CPP_DL_PEDWARN, CPP_DL_ERROR,
	CPP_DL_ICE, CPP_DL_NOTE, CPP_DL_FATAL): Replace macros with enums.
	(CPP_W_NONE, CPP_W_DEPRECATED, CPP_W_COMMENTS,
	CPP_W_MISSING_INCLUDE_DIRS, CPP_W_TRIGRAPHS, CPP_W_MULTICHAR,
	CPP_W_TRADITIONAL, CPP_W_LONG_LONG, CPP_W_ENDIF_LABELS,
	CPP_W_NUM_SIGN_CHANGE, CPP_W_VARIADIC_MACROS,
	CPP_W_BUILTIN_MACRO_REDEFINED, CPP_W_DOLLARS, CPP_W_UNDEF,
	CPP_W_UNUSED_MACROS, CPP_W_CXX_OPERATOR_NAMES, CPP_W_NORMALIZE,
	CPP_W_INVALID_PCH, CPP_W_WARNING_DIRECTIVE): New enums for cpp
	warning reason codes.
	(cpp_warning, cpp_pedwarning, cpp_warning_syshdr,
	cpp_warning_with_line, cpp_pedwarning_with_line,
	cpp_warning_with_line_syshdr): New specific error reporting functions.
	* pch.c (cpp_valid_state): Call specific warning functions with
        warning reason where appropriate.
	* errors.c (cpp_diagnostic, cpp_diagnostic_with_line): New central
	diagnostic handlers.
	(cpp_warning, cpp_pedwarning, cpp_warning_syshdr,
	cpp_warning_with_line, cpp_pedwarning_with_line,
	cpp_warning_with_line_syshdr): New specific error reporting functions.
	* expr.c (cpp_classify_number, eval_token, num_unary_op): Call
	specific warning functions with warning reason where appropriate.
	* lex.c (_cpp_process_line_notes, _cpp_skip_block_comment,
	warn_about_normalization, lex_identifier_intern, lex_identifier,
	_cpp_lex_direct): Ditto.
	* charset.c (_cpp_valid_ucn, convert_hex, convert_escape,
	narrow_str_to_charconst): Ditto.

	* gcc.dg/cpp/warn-undef-2.c: New.
	* gcc.dg/cpp/warn-traditional-2.c: New.
	* gcc.dg/cpp/warn-comments-2.c: New.
	* gcc.dg/cpp/warning-directive-1.c: New.
	* gcc.dg/cpp/warn-long-long.c: New.
	* gcc.dg/cpp/warn-traditional.c: New.
	* gcc.dg/cpp/warn-variadic-2.c: New.
	* gcc.dg/cpp/warn-undef.c: New.
	* gcc.dg/cpp/warn-normalized-1.c: New.
	* gcc.dg/cpp/warning-directive-2.c: New.
	* gcc.dg/cpp/warn-long-long-2.c: New.
	* gcc.dg/cpp/warn-variadic.c: New.
	* gcc.dg/cpp/warn-normalized-2.c: New.
	* gcc.dg/cpp/warning-directive-3.c: New.
	* gcc.dg/cpp/warn-deprecated-2.c: New.
	* gcc.dg/cpp/warn-trigraphs-1.c: New.
	* gcc.dg/cpp/warn-multichar-2.c: New.
	* gcc.dg/cpp/warn-normalized-3.c: New.
	* gcc.dg/cpp/warning-directive-4.c: New.
	* gcc.dg/cpp/warn-unused-macros.c: New.
	* gcc.dg/cpp/warn-trigraphs-2.c: New.
	* gcc.dg/cpp/warn-cxx-compat-2.c: New.
	* gcc.dg/cpp/warn-cxx-compat.c: New.
	* gcc.dg/cpp/warn-redefined.c: New.
	* gcc.dg/cpp/warn-trigraphs-3.c: New.
	* gcc.dg/cpp/warn-unused-macros-2.c: New.
	* gcc.dg/cpp/warn-deprecated.c: New.
	* gcc.dg/cpp/warn-trigraphs-4.c: New.
	* gcc.dg/cpp/warn-redefined-2.c: New.
	* gcc.dg/cpp/warn-comments.c: New.
	* gcc.dg/cpp/warn-multichar.c: New.
	* g++.dg/cpp/warning-directive-1.C: New.
	* g++.dg/cpp/warning-directive-2.C: New.
	* g++.dg/cpp/warning-directive-3.C: New.
	* g++.dg/cpp/warning-directive-4.C: New.
	* gfortran.dg/warning-directive-1.F90: New.
	* gfortran.dg/warning-directive-3.F90: New.
	* gfortran.dg/warning-directive-2.F90: New.
	* gfortran.dg/warning-directive-4.F90: New.

From-SVN: r158079
2010-04-07 17:18:10 +00:00
Arnaud Charlet 3de8a540d8 macro.c (enter_macro_context): Call cb.used callback if defined.
* macro.c (enter_macro_context): Call cb.used callback if defined.
	* directives.c (do_idef, do_ifndef): Ditto.
	* include/cpplib.h (struct cpp_callbacks): Add used callback.

From-SVN: r154359
2009-11-20 09:18:16 +01:00
Kai Tietz 17e7cb8550 ChangeLog for libcpp
2009-11-11  Kai Tietz  <kai.tietz@onevision.com>

	* directives.c (do_pragma_push_macro): New pragma handler.
	(do_pragma_pop_macro): Likewise.
	(_cpp_init_internal_pragmas): Add push_macro and
	pop_macro handler to internal pragmas.
	(lex_macro_node_from_str): Removed.
	(cpp_push_definition): Replace lex_macro_node_from_str
	by _cpp_lex_identifier.
	(cpp_pop_definition): Likewise.
	* internal.h (_cpp_lex_identifier): New prototype.
	(def_pragma_macro): New structure.
	(cpp_reader): New member pushed_macros.
	* lex.c (_cpp_lex_identifier): New function.
	(lex_identifier_intern): New function.
	* init.c (cpp_create_reader): Initialize pushed_macros
	member.
	(cpp_destroy): Free elements in pushed_macros member.
	* pch.c (_cpp_save_pushed_macros): New function.
	(_cpp_restore_pushed_macros): Likewise.
	(_cpp_restore_pushed_macros): Use _cpp_save_pushed_macros.
	(cpp_read_state): Use _cpp_restore_pushed_macros.

ChangeLog for gcc

2009-11-11  Kai Tietz  <kai.tietz@onevision.com>

	* config/i386/cygming.h (HANDLE_PRAGMA_PUSH_POP_MACRO):
	Removed.
	* c-pragma.c (def_pragma_macro_value): Likewise.
	(def_pragma_macro): Likewise.
	(pushed_macro_table): Likewise.
	(HANDLE_PRAGMA_PUSH_POP_MACRO): Remove guarded
	code.
	* doc/tm.texi (HANDLE_PRAGMA_PUSH_POP_MACRO):
	Removed.

ChangeLog for gcc/testsuite

2009-11-11  Kai Tietz  <kai.tietz@onevision.com>

	* g++.dg/torture/pushpop_macro.C: New testcase.
	* gcc.c-torture/execute/pushpop_macro.c: New testcase.
	* gcc.dg/cpp/pragma-pop_macro-1.c: Allow test for all
	targets.

From-SVN: r154098
2009-11-11 19:37:19 +01:00
Jakub Jelinek 2c6e3f5540 charset.c (cpp_init_iconv): Initialize utf8_cset_desc.
* charset.c (cpp_init_iconv): Initialize utf8_cset_desc.
	(_cpp_destroy_iconv): Destroy utf8_cset_desc, char16_cset_desc
	and char32_cset_desc.
	(converter_for_type): Handle CPP_UTF8STRING.
	(cpp_interpret_string): Handle CPP_UTF8STRING and raw-strings.
	* directives.c (get__Pragma_string): Handle CPP_UTF8STRING.
	(parse_include): Reject raw strings.
	* include/cpplib.h (CPP_UTF8STRING): New token type.
	* internal.h (struct cpp_reader): Add utf8_cset_desc field.
	* lex.c (lex_raw_string): New function.
	(lex_string): Handle u8 string literals, call lex_raw_string
	for raw string literals.
	(_cpp_lex_direct): Call lex_string even for u8" and {,u,U,L,u8}R"
	sequences.
	* macro.c (stringify_arg): Handle CPP_UTF8STRING.

	* c-common.c (c_parse_error): Handle CPP_UTF8STRING.
	* c-lex.c (c_lex_with_flags): Likewise.  Test C_LEX_STRING_NO_JOIN
	instead of C_LEX_RAW_STRINGS.
	(lex_string): Handle CPP_UTF8STRING.
	* c-parser.c (c_parser_postfix_expression): Likewise.
	* c-pragma.h (C_LEX_RAW_STRINGS): Rename to ...
	(C_LEX_STRING_NO_JOIN): ... this.

	* parser.c (cp_lexer_print_token, cp_parser_is_string_literal,
	cp_parser_string_literal, cp_parser_primary_expression): Likewise.
	(cp_lexer_get_preprocessor_token): Use C_LEX_STRING_JOIN instead
	of C_LEX_RAW_STRINGS.

	* gcc.dg/raw-string-1.c: New test.
	* gcc.dg/raw-string-2.c: New test.
	* gcc.dg/raw-string-3.c: New test.
	* gcc.dg/raw-string-4.c: New test.
	* gcc.dg/raw-string-5.c: New test.
	* gcc.dg/raw-string-6.c: New test.
	* gcc.dg/raw-string-7.c: New test.
	* gcc.dg/utf8-1.c: New test.
	* gcc.dg/utf8-2.c: New test.
	* gcc.dg/utf-badconcat2.c: New test.
	* gcc.dg/utf-dflt2.c: New test.
	* gcc.dg/cpp/include6.c: New test.
	* g++.dg/ext/raw-string-1.C: New test.
	* g++.dg/ext/raw-string-2.C: New test.
	* g++.dg/ext/raw-string-3.C: New test.
	* g++.dg/ext/raw-string-4.C: New test.
	* g++.dg/ext/raw-string-5.C: New test.
	* g++.dg/ext/raw-string-6.C: New test.
	* g++.dg/ext/raw-string-7.C: New test.
	* g++.dg/ext/utf8-1.C: New test.
	* g++.dg/ext/utf8-2.C: New test.
	* g++.dg/ext/utf-badconcat2.C: New test.
	* g++.dg/ext/utf-dflt2.C: New test.

From-SVN: r152995
2009-10-19 23:41:15 +02:00
Neil Vachharajani 2214382ca9 directives.c (DIRECTIVE_TABLE): Remove DEPRECATED from ident and sccs.
2009-10-09  Neil Vachharajani <nvachhar@google.com>

       * libcpp/directives.c (DIRECTIVE_TABLE): Remove DEPRECATED from ident and
       sccs.

       * gcc/doc/cpp.texi (Other Directives): Do not list #ident and #sccs as
       deprecated.

From-SVN: r152612
2009-10-10 00:34:21 +00:00
Jason Merrill 86373e7e61 dbgcnt.c (dbg_cnt_process_single_pair): constify.
gcc/
	* dbgcnt.c (dbg_cnt_process_single_pair): constify.
	* opts.c (common_handle_option): constify.
gcc/cp/
	* repo.c (extract_string, get_base_filename, init_repo): constify.
libcpp/
	* directives.c (cpp_define): constify.

From-SVN: r151661
2009-09-12 15:46:45 -04:00
Jerry Quinn f1bf410cad directives.c (do_linemarker, do_line): Use CPP_STRING for ignored enum value.
2009-07-17  Jerry Quinn  <jlquinn@optonline.net>

	* directives.c (do_linemarker, do_line): Use CPP_STRING for
	ignored enum value.
	* files.c (find_file_in_dir): Add cast from void* to char*.
	* symtab.c (ht_lookup_with_hash): Add cast from void* to char*.
	* Makefile.in: (WARN_CFLAGS): Use general and C-specific
	warnings.
	(CXX, CXXFLAGS, WARN_CXXFLAGS, ALL_CXXFLAGS,
	ENABLE_BUILD_WITH_CXX, CCDEPMODE, CXXDEPMODE, COMPILER,
	COMPILER_FLAGS): New.
	(DEPMODE): Set from CCDEPMODE or CXXDEPMODE.
	(COMPILE.base): Use COMPILER instead of CC.  Use COMPILER_FLAGS
	instead of ALL_CFLAGS.
	* configure.ac: Invoke AC_PROG_CXX.  Separate C-specific warnings
	from other warnings.  Add -Wc++-compat to C-specific warnings.
	Check for --enable-build-with-cxx.  Set and substitute
	ENABLE_BUILD_WITH_CXX.  Invoke ZW_PROG_COMPILER_DEPENDENCIES
	according to ENABLE_BUILD_WITH_CXX.  Invoke AC_LANG before
	AC_CHECK_HEADERS.
	* configure: Rebuild.
	* include/cpp-id-data.h: Remove extern "C".
	* include/line-map.h: Likewise.
	* include/mkdeps.h: Likewise.
	* include/symtab.h: Likewise.
	* internal.h: Likewise.

From-SVN: r149763
2009-07-18 03:22:16 +00:00
Manuel López-Ibáñez a28fbdbac8 directives.c (parse_include): Add location argument.
2009-06-23  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

libcpp/
	* directives.c (parse_include): Add location argument. Update all
	calls.
	(parse_answer): Likewise.
	(do_include_common): Error with exact location.
	(parse_assertion): Likewise.
testsuite/
	* gcc.dg/cpp/empty-include.c: Update column info.
	* gcc.dg/cpp/assert2.c: Update column info.

From-SVN: r148857
2009-06-23 16:30:58 +00:00
Manuel López-Ibáñez 00b0c19b4b re PR preprocessor/36674 (#include location is offset by one row in errors from preprocessed files)
2009-05-14  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

	PR cpp/36674
libcpp/
	* directives (do_linemarker): Compensate for the increment in
	location that occurs when we reach the end of line.
	* files (_cpp_stack_include): Mention _cpp_find_file in the
	comment.
testsuite/
	* gcc.dg/cpp/pr36674.i: New.

From-SVN: r147504
2009-05-13 23:17:55 +00:00
Joseph Myers 9a0c618755 c-lex.c (c_lex_with_flags): Expect cpp_hashnode in tok->val.node.node.
gcc:
	* c-lex.c (c_lex_with_flags): Expect cpp_hashnode in
	tok->val.node.node.

libcpp:
	* include/cpplib.h (enum cpp_token_fld_kind): Add
	CPP_TOKEN_FLD_TOKEN_NO.
	(struct cpp_macro_arg, struct cpp_identifier): Define.
	(union cpp_token_u): Use struct cpp_identifier for identifiers.
	Use struct cpp_macro_arg for macro arguments.  Add token_no for
	CPP_PASTE token numbers.
	* directives.c (_cpp_handle_directive, lex_macro_node, do_pragma,
	do_pragma_poison, parse_assertion): Use val.node.node in place of
	val.node.
	* expr.c (parse_defined, eval_token): Use val.node.node in place
	of val.node.
	* lex.c (cpp_ideq, _cpp_lex_direct, cpp_token_len,
	cpp_spell_token, cpp_output_token, _cpp_equiv_tokens,
	cpp_token_val_index): Use val.macro_arg.arg_no or val.token_no in
	place of val.arg_no.  Use val.node.node in place of val.node.
	* macro.c (replace_args, cpp_get_token, parse_params,
	lex_expansion_token, create_iso_definition, cpp_macro_definition):
	Use val.macro_arg.arg_no or val.token_no in place of val.arg_no.
	Use val.node.node in place of val.node.

From-SVN: r147341
2009-05-10 15:27:32 +01:00
Joseph Myers 61cc82231b directives.c (parse_include): Pass true to check_eol.
libcpp:
	* directives.c (parse_include): Pass true to check_eol.

gcc/testsuite:
	* gcc.dg/cpp/include5.c: New test.

From-SVN: r146327
2009-04-18 21:25:07 +01:00
Joseph Myers c7f9c0b983 re PR preprocessor/39646 (__FILE__ breaks for empty file name)
libcpp:
	PR preprocessor/39646
	* include/line-map.h (enum lc_reason): Add LC_RENAME_VERBATIM.
	* line-map.c (linemap_add): Handle LC_RENAME_VERBATIM.
	* directives.c (do_line, do_linemarker): Use LC_RENAME_VERBATIM in
	place of LC_RENAME.

gcc/testsuite:
	* gcc.dg/cpp/line8.c: New test.

From-SVN: r146319
2009-04-18 18:36:28 +01:00
Joseph Myers a5cb563b79 re PR preprocessor/39647 (Syntax checks in #line not quite right)
libcpp:
	PR preprocessor/39647
	* directives.c (check_eol): Add parameter expand.
	(do_undef, parse_include, do_line, do_linemarker, do_ident,
	do_pragma_once, do_pragma_system_header, do_ifdef, do_ifndef,
	do_else, do_endif, do_assert, do_unassert): All callers changed.
	Pass true from do_line, false elsewhere.

gcc/testsuite:
	* gcc.dg/cpp/line7.c: New test.

From-SVN: r146316
2009-04-18 16:28:40 +01:00
Jakub Jelinek 748086b7b2 Licensing changes to GPLv3 resp. GPLv3 with GCC Runtime Exception.
From-SVN: r145841
2009-04-09 17:00:19 +02:00
Joseph Myers 148e4216a4 re PR preprocessor/34695 (Preprocessor warning->error conversion from -Werror is silent)
PR preprocessor/34695

gcc:
	* Makefile.in (c-opts.o): Depend on c-tree.h.
	* c-common.c: Move down include of diagnostic.h.
	(done_lexing, c_cpp_error): New.
	* c-common.h (done_lexing): Declare.
	* c-decl.c (c_write_global_declarations): Don't check cpp_errors
	(parse_in).
	* c-opts.c: Include c-tree.h.
	(c_common_init_options): Set preprocessor error callback.
	(c_common_handle_option): Do not set preprocessor
	inhibit_warnings, warnings_are_errors, warn_system_headers,
	pedantic_errors or inhibit_warnings flags.
	(c_common_post_options): Do not check cpp_errors (parse_in).
	(c_common_finish): Do not output dependencies if there were
	errors.  Do not check return value of cpp_finish.
	* c-ppoutput.c (pp_file_change): Set input_location.
	* c-tree.h (c_cpp_error): Declare.
	* diagnostic.c (diagnostic_set_info_translated): Also initialize
	override_column.
	(diagnostic_build_prefix): Check override_column.
	* diagnostic.h (diagnostic_info): Add override_column field.
	(diagnostic_override_column): Define.

gcc/cp:
	* cp-tree.h (cp_cpp_error): Remove.
	* error.c (cp_cpp_error): Remove.
	* parser.c (cp_lexer_new_main): Set done_lexing instead of
	client_diagnostic and error callback.

gcc/fortran:
	* cpp.c (cb_cpp_error): New.
	(gfc_cpp_post_options): Don't set cpp_option->inhibit_warnings.
	Don't check cpp_errors (cpp_in).
	(gfc_cpp_init_0): Set cb->error.

gcc/testsuite:
	* gcc.dg/builtin-redefine.c, gcc.dg/cpp/redef2.c,
	gcc.dg/cpp/redef3.c, gcc.dg/cpp/trad/redef2.c: Use dg-message
	instead of dg-warning for "previous definition" messages.
	* gcc.dg/cpp/Wvariadic-1.c, gcc.dg/cpp/Wvariadic-3.c: Expect
	"warnings being treated as errors" message.
	* gcc.dg/fltconst-1.c: Use -fshow-column.

libcpp:
	* makedepend.c: Remove.
	* Makefile.in (makedepend_OBJS, makedepend$(EXEEXT)): Remove.
	(all, clean, TAGS_SOURCES, include): Remove makedepend handling.
	* directives.c (cpp_errors): Remove.
	* errors.c (print_location, _cpp_begin_message, v_message):
	Remove.
	(cpp_error, cpp_error_with_line): Always use error callback.
	(cpp_error, cpp_error_with_line, cpp_errno): Return bool.
	* include/cpplib.h (cpp_options): Remove pedantic_errors,
	inhibit_warnings, warn_system_headers, inhibit_errors,
	warnings_are_errors, client_diagnostic.
	(cpp_callbacks): Add extra arguments to error callback; make it
	return bool.
	(cpp_finish): Return void.
	(cpp_destroy): Remove inaccurate comment about return value.
	(cpp_errors, CPP_DL_EXTRACT, CPP_DL_WARNING_P): Remove.
	(CPP_DL_NOTE): Define.
	* include/line-map.h (linemap_print_containing_files): Remove.
	* init.c (cpp_finish): Do not check for or return number of
	errors.
	* internal.h (cpp_reader): Remove errors field.
	* line-map.c (linemap_print_containing_files): Remove.
	* macro.c (_cpp_create_definition): Use CPP_DL_NOTE for message
	about previous definition.  Only emit it if previous diagnostic
	was emitted.

From-SVN: r145263
2009-03-29 23:56:07 +01:00
Manuel López-Ibáñez 3b8f20a10d re PR preprocessor/28079 (#line range not verified without -pedantic)
2008-07-22  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

	PR 28079
libcpp/
	* directives.c (strtolinenum): Handle overflow.
	(do_line): Give a warning if line number overflowed.
	(do_linemarker): Update call to strtolinenum.

gcc/testsuite/
	* gcc.dg/cpp/line6.c: New.

From-SVN: r138049
2008-07-22 09:45:58 +00:00
Manuel López-Ibáñez 1bb64668d0 line-map.h (linenum_type): New typedef.
2008-07-21  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

	* include/line-map.h (linenum_type): New typedef.
	(struct line_map): Use it.
	(SOURCE_LINE): Second arguments is a LOCATION not a LINE.
	(SOURCE_COLUMN): Likewise.
	* macro.c (_cpp_builtin_macro_text): Use linenum_type. Don't store
	source_location values in a variable of type linenum_type.
	* directives.c (struct if_stack): Use linenum_type.
	(strtoul_for_line): Rename as strtolinenum.
	(do_line): Use linenum_type.
	(do_linemarker): Use linenum_type and strtolinenum.
	(_cpp_do_file_change): Use linenum_t.
	* line-map.c (linemap_add): Likewise.
	(linemap_line_start): Likewise.
	* traditional.c (struct fun_macro): 'line' is a source_location.
	* errors.c (print_location): Use linenum_type.
	* directives-only.c (_cpp_preprocess_dir_only): Likewise.
	* internal.h (CPP_INCREMENT_LINE): Likewise.
	* lex.c (_cpp_skip_block_comment): Use source_location.

From-SVN: r138026
2008-07-21 09:33:38 +00:00
Tom Tromey d750887f5f re PR preprocessor/36320 (Required diagnosis of syntax error missed)
gcc/testsuite
	PR preprocessor/36320:
	* gcc.dg/cpp/pr36320.c: New file.
libcpp
	PR preprocessor/36320:
	* internal.h (_cpp_parse_expr): Update.
	* expr.c (_cpp_parse_expr): Add 'is_if' argument.  Update error
	messages.
	* directives.c (do_if): Update.
	(do_elif): Require expression if processing group.

From-SVN: r136209
2008-05-30 14:25:09 +00:00
Tom Tromey 5d6342ebc2 re PR preprocessor/27777 (Bad diagnostic emission when #error contains a trigraph)
gcc/testsuite
	PR preprocessor/27777:
	* gcc.dg/cpp/pr27777.c: New file.
libcpp
	PR preprocessor/27777:
	* lex.c (cpp_output_line_to_string): New function.
	* internal.h (_cpp_begin_message): Don't declare.
	* errors.c (_cpp_begin_message): Now static.
	* include/cpplib.h (cpp_output_line_to_string): Declare.
	* directives.c (do_diagnostic): Rewrote.  Use
	cpp_output_line_to_string.  Don't use _cpp_begin_message.

From-SVN: r135740
2008-05-21 21:52:57 +00:00
Tom Tromey 899015a064 re PR preprocessor/22168 (#if #A == #B should have a diagnostic in ISO C mode)
libcpp
	PR preprocessor/22168:
	* include/cpplib.h (struct cpp_options) <objc>: Update
	documentation.
	* expr.c (eval_token): Warn for use of assertions.
	* directives.c (directive_diagnostics): Warn about extensions.
	(DEPRECATED): New define.
	(DIRECTIVE_TABLE): Use it.
gcc
	PR preprocessor/22168:
	* doc/cpp.texi (Top): Update menu.
	(Alternatives to Wrapper #ifndef): New node.
	(Other Directives): Document deprecation.
	(Obsolete Features): Remove menu.
	(Assertions): Merge node into Obsolete Features.
	(Obsolete once-only headers): Move earlier; rename to Alternatives
	to Wrapper #ifndef.
	* doc/cppopts.texi: Update.
	* c.opt (Wdeprecated): Enable for C and ObjC.
	* doc/invoke.texi (Option Summary): Move -Wno-deprecated.
	(C++ Dialect Options): Move -Wno-deprecated from here to...
	(Warning Options): ... here.
gcc/testsuite
	PR preprocessor/22168:
	* gcc.dg/pch/import-2.hs: Add -Wno-deprecated.
	* gcc.dg/pch/import-1.hs: Add -Wno-deprecated.
	* gcc.dg/pch/import-2.c: Add -Wno-deprecated.
	* gcc.dg/pch/import-1.c: Add -Wno-deprecated.
	* gcc.dg/cpp/import2.c: Add -Wno-deprecated.
	* gcc.dg/cpp/import1.c: Add -Wno-deprecated.
	* gcc.dg/cpp/trad/assert3.c: Add -Wno-deprecated.
	* gcc.dg/cpp/trad/assert2.c: Add -Wno-deprecated.
	* gcc.dg/cpp/trad/assert1.c: Add -Wno-deprecated.
	* gcc.dg/cpp/ident.c: Add -Wno-deprecated.
	* gcc.dg/cpp/ident-1.c: Add -Wno-deprecated.
	* gcc.dg/cpp/extratokens.c: Add -Wno-deprecated.
	* gcc.dg/cpp/assert3.c: Add -Wno-deprecated.
	* gcc.dg/cpp/assert2.c: Add -Wno-deprecated.
	* gcc.dg/cpp/assert1.c: Add -Wno-deprecated.
	* gcc.dg/cpp/assert4.c: Compile with -ansi and not -pedantic.  Add
	-Wno-deprecated.
	* gcc.dg/cpp/pr22168.c: New file.
	* gcc.dg/cpp/pr22168-2.c: New file.

From-SVN: r135264
2008-05-13 14:50:27 +00:00
Daniel Franke 28f6862553 cpplib.h (cpp_define_formatted): New.
2008-04-22  Daniel Franke  <franke.daniel@gmail.com>

        * include/cpplib.h (cpp_define_formatted): New.
        * directives.c (cpp_define_formatted): New.

From-SVN: r134564
2008-04-22 14:04:32 -04:00
Kris Van Hees b6baa67d79 cpp-id-data.h (UC): Was U, conflicts with U...
libcpp/ChangeLog:
2008-04-14  Kris Van Hees <kris.van.hees@oracle.com>

* include/cpp-id-data.h (UC): Was U, conflicts with U... literal.
* include/cpplib.h (CHAR16, CHAR32, STRING16, STRING32): New tokens.
(struct cpp_options): Added uliterals.
(cpp_interpret_string): Update prototype.
(cpp_interpret_string_notranslate): Idem.
* charset.c (init_iconv_desc): New width member in cset_converter.
(cpp_init_iconv): Add support for char{16,32}_cset_desc.
(convert_ucn): Idem.
(emit_numeric_escape): Idem.
(convert_hex): Idem.
(convert_oct): Idem.
(convert_escape): Idem.
(converter_for_type): New function.
(cpp_interpret_string): Use converter_for_type, support u and U prefix.
(cpp_interpret_string_notranslate): Match changed prototype.
(wide_str_to_charconst): Use converter_for_type.
(cpp_interpret_charconst): Add support for CPP_CHAR{16,32}.
* directives.c (linemarker_dir): Macro U changed to UC.
(parse_include): Idem.
(register_pragma_1): Idem.
(restore_registered_pragmas): Idem.
(get__Pragma_string): Support CPP_STRING{16,32}.
* expr.c (eval_token): Support CPP_CHAR{16,32}.
* init.c (struct lang_flags): Added uliterals.
(lang_defaults): Idem.
* internal.h (struct cset_converter) <width>: New field.
(struct cpp_reader) <char16_cset_desc>: Idem.
(struct cpp_reader) <char32_cset_desc>: Idem.
* lex.c (digraph_spellings): Macro U changed to UC.
(OP, TK): Idem.
(lex_string): Add support for u'...', U'...', u... and U....
(_cpp_lex_direct): Idem.
* macro.c (_cpp_builtin_macro_text): Macro U changed to UC.
(stringify_arg): Support CPP_CHAR{16,32} and CPP_STRING{16,32}.

gcc/ChangeLog:
2008-04-14  Kris Van Hees <kris.van.hees@oracle.com>
  
* c-common.c (CHAR16_TYPE, CHAR32_TYPE): New macros.
(fname_as_string): Match updated cpp_interpret_string prototype.
(fix_string_type): Support char16_t* and char32_t*.
(c_common_nodes_and_builtins): Add char16_t and char32_t (and
derivative) nodes.  Register as builtin if C++0x.
(c_parse_error): Support CPP_CHAR{16,32}.
* c-common.h (RID_CHAR16, RID_CHAR32): New elements. 
(enum c_tree_index) <CTI_CHAR16_TYPE, CTI_SIGNED_CHAR16_TYPE,
CTI_UNSIGNED_CHAR16_TYPE, CTI_CHAR32_TYPE, CTI_SIGNED_CHAR32_TYPE,
CTI_UNSIGNED_CHAR32_TYPE, CTI_CHAR16_ARRAY_TYPE,
CTI_CHAR32_ARRAY_TYPE>: New elements.
(char16_type_node, signed_char16_type_node, unsigned_char16_type_node,
char32_type_node, signed_char32_type_node, char16_array_type_node,
char32_array_type_node): New defines.
* c-lex.c (cb_ident): Match updated cpp_interpret_string prototype.
(c_lex_with_flags): Support CPP_CHAR{16,32} and CPP_STRING{16,32}.
(lex_string): Support CPP_STRING{16,32}, match updated
cpp_interpret_string and cpp_interpret_string_notranslate prototypes.
(lex_charconst): Support CPP_CHAR{16,32}.
* c-parser.c (c_parser_postfix_expression): Support CPP_CHAR{16,32}
and CPP_STRING{16,32}.

gcc/cp/ChangeLog:
2008-04-14  Kris Van Hees <kris.van.hees@oracle.com>

* cvt.c (type_promotes_to): Support char16_t and char32_t.
* decl.c (grokdeclarator): Disallow signed/unsigned/short/long on
char16_t and char32_t.
* lex.c (reswords): Add char16_t and char32_t (for c++0x).
* mangle.c (write_builtin_type): Mangle char16_t/char32_t as vendor
extended builtin type u8char32_t.
* parser.c (cp_lexer_next_token_is_decl_specifier_keyword): Support
RID_CHAR{16,32}.
(cp_lexer_print_token): Support CPP_STRING{16,32}.
(cp_parser_is_string_literal): Idem.
(cp_parser_string_literal): Idem.
(cp_parser_primary_expression): Support CPP_CHAR{16,32} and
CPP_STRING{16,32}.
(cp_parser_simple_type_specifier): Support RID_CHAR{16,32}. 
* tree.c (char_type_p): Support char16_t and char32_t as char types.
* typeck.c (string_conv_p): Support char16_t and char32_t.

gcc/testsuite/ChangeLog:
2008-04-14  Kris Van Hees <kris.van.hees@oracle.com>

Tests for char16_t and char32_t support.
* g++.dg/ext/utf-cvt.C: New
* g++.dg/ext/utf-cxx0x.C: New
* g++.dg/ext/utf-cxx98.C: New
* g++.dg/ext/utf-dflt.C: New
* g++.dg/ext/utf-gnuxx0x.C: New
* g++.dg/ext/utf-gnuxx98.C: New
* g++.dg/ext/utf-mangle.C: New
* g++.dg/ext/utf-typedef-cxx0x.C: New
* g++.dg/ext/utf-typedef-
* g++.dg/ext/utf-typespec.C: New
* g++.dg/ext/utf16-1.C: New
* g++.dg/ext/utf16-2.C: New
* g++.dg/ext/utf16-3.C: New
* g++.dg/ext/utf16-4.C: New
* g++.dg/ext/utf32-1.C: New
* g++.dg/ext/utf32-2.C: New
* g++.dg/ext/utf32-3.C: New
* g++.dg/ext/utf32-4.C: New
* gcc.dg/utf-cvt.c: New
* gcc.dg/utf-dflt.c: New
* gcc.dg/utf16-1.c: New
* gcc.dg/utf16-2.c: New
* gcc.dg/utf16-3.c: New
* gcc.dg/utf16-4.c: New
* gcc.dg/utf32-1.c: New
* gcc.dg/utf32-2.c: New
* gcc.dg/utf32-3.c: New
* gcc.dg/utf32-4.c: New

libiberty/ChangeLog:
2008-04-14  Kris Van Hees <kris.van.hees@oracle.com>

* testsuite/demangle-expected: Added tests for char16_t and char32_t.

From-SVN: r134438
2008-04-18 09:58:08 -04:00
Joseph Myers 93d45d9eda cppopts.texi (-dU): Document.
gcc:
	* doc/cppopts.texi (-dU): Document.
	* c-common.h (flag_dump_macros): Update comment.
	* c-opts.c (handle_OPT_d): Handle -dU.
	* c-ppoutput.c (macro_queue, define_queue, undef_queue,
	dump_queued_macros, cb_used_define, cb_used_undef): New.
	(init_pp_output): Handle -dU.
	(cb_line_change): Call dump_queued_macros.
	* toplev.c (decode_d_option): Accept -dU as preprocessor option.

gcc/testsuite:
	* gcc.dg/cpp/cmdlne-dU-1.c, gcc.dg/cpp/cmdlne-dU-2.c,
	gcc.dg/cpp/cmdlne-dU-3.c, gcc.dg/cpp/cmdlne-dU-4.c,
	gcc.dg/cpp/cmdlne-dU-5.c, gcc.dg/cpp/cmdlne-dU-6.c,
	gcc.dg/cpp/cmdlne-dU-7.c, gcc.dg/cpp/cmdlne-dU-8.c,
	gcc.dg/cpp/cmdlne-dU-9.c, gcc.dg/cpp/cmdlne-dU-10.c,
	gcc.dg/cpp/cmdlne-dU-11.c, gcc.dg/cpp/cmdlne-dU-12.c,
	gcc.dg/cpp/cmdlne-dU-13.c, gcc.dg/cpp/cmdlne-dU-14.c,
	gcc.dg/cpp/cmdlne-dU-15.c, gcc.dg/cpp/cmdlne-dU-16.c,
	gcc.dg/cpp/cmdlne-dU-17.c, gcc.dg/cpp/cmdlne-dU-18.c,
	gcc.dg/cpp/cmdlne-dU-19.c, gcc.dg/cpp/cmdlne-dU-20.c,
	gcc.dg/cpp/cmdlne-dU-21.c, gcc.dg/cpp/cmdlne-dU-22.c: New tests.

libcpp:
	* include/cpplib.h (struct cpp_callbacks): Add used_define,
	used_undef and before_define.
	(NODE_USED): Define.
	* directives.c (do_define, do_undef, undefine_macros, do_ifdef,
	do_ifndef, cpp_pop_definition): Handle new flag and use new
	callbacks.
	* expr.c (parse_defined): Handle new flag and use new callbacks.
	* macro.c (enter_macro_context, _cpp_free_definition): Handle new
	flag and use new callbacks.

From-SVN: r133847
2008-04-02 20:42:53 +01:00