Skip to content
Snippets Groups Projects
  1. Mar 06, 2013
    • Jakub Jelinek's avatar
      re PR middle-end/56461 (GCC is leaking lots of memory) · 28937f11
      Jakub Jelinek authored
      	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
      28937f11
  2. Jan 14, 2013
  3. Oct 04, 2012
    • Florian Weimer's avatar
      Implement #pragma GCC warning/error · f591bd8f
      Florian Weimer authored
      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
      f591bd8f
  4. Aug 27, 2012
    • Dodji Seketeli's avatar
      PR preprocessor/53469 - argument tokens of _Pragma miss virtual location · f3d25c65
      Dodji Seketeli authored
      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
      f3d25c65
  5. May 29, 2012
    • Joseph Myers's avatar
      directives.c: Fix typos. · 7d9641cc
      Joseph Myers authored
      	* directives.c: Fix typos.
      	* include/line-map.h: Fix typos.
      	* line-map.c: Fix typos.
      	* macro.c: Fix typos.
      
      From-SVN: r187966
      7d9641cc
    • Dodji Seketeli's avatar
      PR preprocessor/53229 - Fix diagnostics location when pasting tokens · 828a7f76
      Dodji Seketeli authored
      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
      828a7f76
  6. May 02, 2012
    • Dodji Seketeli's avatar
      Properly initialize cpp_context in destringize_and_run · 3ad64f53
      Dodji Seketeli authored
      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
      3ad64f53
  7. Oct 17, 2011
    • Tom Tromey's avatar
      Generate virtual locations for tokens · 92582b75
      Tom Tromey authored
      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: default avatarDodji Seketeli <dodji@redhat.com>
      
      From-SVN: r180082
      92582b75
    • Tom Tromey's avatar
      Linemap infrastructure for virtual locations · 46427374
      Tom Tromey authored
      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
      46427374
  8. Jul 15, 2011
    • Dodji Seketeli's avatar
      Use source_location where it is due · d0a9fbe1
      Dodji Seketeli authored
      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
      d0a9fbe1
  9. Jun 06, 2011
  10. Mar 21, 2011
  11. Jan 04, 2011
  12. Sep 29, 2010
    • Kai Tietz's avatar
      re PR preprocessor/45362 (Dangling reference about saved cpp_macro for push/pop macro) · d6874138
      Kai Tietz authored
      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
      d6874138
    • Joseph Myers's avatar
      optc-gen.awk: Generate global_options initializer instead of individual variables. · e3339d0f
      Joseph Myers authored
      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
      e3339d0f
  13. Aug 31, 2010
  14. Apr 07, 2010
    • Simon Baldwin's avatar
      diagnostic.h (diagnostic_override_option_index): New macro to set a diagnostic's option_index. · 87cf0651
      Simon Baldwin authored
      	* 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
      87cf0651
  15. Nov 20, 2009
  16. Nov 11, 2009
    • Kai Tietz's avatar
      ChangeLog for libcpp · 17e7cb85
      Kai Tietz authored
      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
      17e7cb85
  17. Oct 19, 2009
    • Jakub Jelinek's avatar
      charset.c (cpp_init_iconv): Initialize utf8_cset_desc. · 2c6e3f55
      Jakub Jelinek authored
      	* 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
      2c6e3f55
  18. Oct 10, 2009
  19. Sep 12, 2009
    • Jason Merrill's avatar
      dbgcnt.c (dbg_cnt_process_single_pair): constify. · 86373e7e
      Jason Merrill authored
      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
      86373e7e
  20. Jul 18, 2009
    • Jerry Quinn's avatar
      directives.c (do_linemarker, do_line): Use CPP_STRING for ignored enum value. · f1bf410c
      Jerry Quinn authored
      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
      f1bf410c
  21. Jun 23, 2009
    • Manuel López-Ibáñez's avatar
      directives.c (parse_include): Add location argument. · a28fbdba
      Manuel López-Ibáñez authored
      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
      a28fbdba
  22. May 13, 2009
  23. May 10, 2009
    • Joseph Myers's avatar
      c-lex.c (c_lex_with_flags): Expect cpp_hashnode in tok->val.node.node. · 9a0c6187
      Joseph Myers authored
      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
      9a0c6187
  24. Apr 18, 2009
    • Joseph Myers's avatar
      directives.c (parse_include): Pass true to check_eol. · 61cc8223
      Joseph Myers authored
      libcpp:
      	* directives.c (parse_include): Pass true to check_eol.
      
      gcc/testsuite:
      	* gcc.dg/cpp/include5.c: New test.
      
      From-SVN: r146327
      61cc8223
    • Joseph Myers's avatar
      re PR preprocessor/39646 (__FILE__ breaks for empty file name) · c7f9c0b9
      Joseph Myers authored
      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
      c7f9c0b9
    • Joseph Myers's avatar
      re PR preprocessor/39647 (Syntax checks in #line not quite right) · a5cb563b
      Joseph Myers authored
      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
      a5cb563b
  25. Apr 09, 2009
  26. Mar 29, 2009
    • Joseph Myers's avatar
      re PR preprocessor/34695 (Preprocessor warning->error conversion from -Werror is silent) · 148e4216
      Joseph Myers authored
      	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
      148e4216
  27. Jul 22, 2008
  28. Jul 21, 2008
    • Manuel López-Ibáñez's avatar
      line-map.h (linenum_type): New typedef. · 1bb64668
      Manuel López-Ibáñez authored
      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
      1bb64668
  29. May 30, 2008
    • Tom Tromey's avatar
      re PR preprocessor/36320 (Required diagnosis of syntax error missed) · d750887f
      Tom Tromey authored
      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
      d750887f
  30. May 21, 2008
    • Tom Tromey's avatar
      re PR preprocessor/27777 (Bad diagnostic emission when #error contains a trigraph) · 5d6342eb
      Tom Tromey authored
      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
      5d6342eb
  31. May 13, 2008
    • Tom Tromey's avatar
      re PR preprocessor/22168 (#if #A == #B should have a diagnostic in ISO C mode) · 899015a0
      Tom Tromey authored
      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
      899015a0
  32. Apr 22, 2008
    • Daniel Franke's avatar
      cpplib.h (cpp_define_formatted): New. · 28f68625
      Daniel Franke authored
      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
      28f68625
  33. Apr 18, 2008
    • Kris Van Hees's avatar
      cpp-id-data.h (UC): Was U, conflicts with U... · b6baa67d
      Kris Van Hees authored
      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
      b6baa67d
  34. Apr 02, 2008
    • Joseph Myers's avatar
      cppopts.texi (-dU): Document. · 93d45d9e
      Joseph Myers authored
      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
      93d45d9e
  35. Mar 13, 2008
Loading