Commit Graph

63 Commits

Author SHA1 Message Date
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
Tom Tromey 14ccf8003e re PR preprocessor/35322 (ICE with incomplete macro)
gcc/testsuite
	PR libcpp/35322:
	* gcc.dg/cpp/pr35322.c: New file.
libcpp
	PR libcpp/35322:
	* directives.c (destringize_and_run): Set pfile->directive.

From-SVN: r133195
2008-03-13 21:10:07 +00:00
Jakub Jelinek 765d600ac5 re PR preprocessor/34692 (Internal error with pragma in macro)
PR preprocessor/34692
	* macro.c (collect_args): Add pragma_buff argument.  Push
	CPP_PRAGMA ... CPP_PRAGMA_EOL tokens to *pragma_buff, rather
	than into arguments.  Reset prevent_expansion and parsing_args
	state at CPP_PRAGMA_EOL/CPP_EOF.
	(funlike_invocation_p): Add pragma_buff argument, pass it through
	to collect_args.
	(enter_macro_context): Add result argument.  Adjust
	funlike_invocation_p caller.  Emit all deferred pragma tokens
	gathered during collect_args before the expansion, add a padding
	token.  Return 2 instead of 1 if any pragma tokens were prepended.
	(cpp_get_token): If enter_macro_context returns 2, don't return
	a padding token, instead cycle to grab CPP_PRAGMA token.
	* directives.c (_cpp_handle_directive): If was_parsing_args
	in deferred pragma, leave parsing_args and prevent_expansion as is.

	* gcc.dg/cpp/pr34692.c: New test.
	* gcc.dg/gomp/pr34692.c: New test.

From-SVN: r131819
2008-01-25 10:01:27 +01:00
Tom Tromey 33ae48375f re PR preprocessor/34602 (Internal error with invalid #line directive)
libcpp
	PR preprocessor/34602.
	* directives.c (do_line): Don't try to spell EOF token.
	(do_linemarker): Add comment.
gcc/testsuite
	PR preprocessor/34602:
	* gcc.dg/cpp/pr34602.c: New file.

From-SVN: r131304
2008-01-03 17:58:26 +00:00
Tom Tromey 5b9a40df4e re PR preprocessor/30786 (ICE on _Pragma at end of file)
gcc/testsuite
	PR preprocessor/30786:
	* gcc.dg/cpp/pr30786.c: New file.
libcpp
	PR preprocessor/30786:
	* macro.c (builtin_macro): Return result of _cpp_do__Pragma.
	* directives.c (_cpp_do__Pragma): Return error status.
	* internal.h (_cpp_do__Pragma): Update.
	* directives.c (get__Pragma_string): Back up if EOF seen.

From-SVN: r129800
2007-10-31 14:50:13 +00:00
Tom Tromey cda5e672d8 re PR preprocessor/32974 (#pragma GCC dependency generates extra token error.)
gcc/testsuite
	PR preprocessor/32974:
	* gcc.dg/cpp/pr32974.c: New file.
libcpp
	PR preprocessor/32974:
	* directives.c (parse_include): Don't check for EOL when
	processing #pragma dependency.

From-SVN: r127614
2007-08-18 17:54:11 +00:00
Ollie Wild ccfc4c91bb directives-only.c: New file.
libcpp/
	* directives-only.c: New file.
	* internal.h (struct _cpp_dir_only_callbacks): New.
	(_cpp_preprocess_dir_only): New function.
	* directives.c (_cpp_handle_directive): Check directives_only before
	disabling execution of indented directives.
	* files.c (_cpp_stack_file): Add directives_only check.
	* include/cpplib.h (struct cpp_options): Add directives_only.
	(cpp_init_special_builtins): New function.
	* init.c (cpp_init_special_builtins): New function.
	(cpp_init_builtins): Move builtin_array initialization to
	cpp_init_special_builtins.
	(post_options): Check directives_only before setting
	pfile->state.prevent_expansion = 1.
	* macro.c (_cpp_builtin_macro_text): Print an error if __COUNTER__
	is expanded inside a directive while -fdirectives-only is enabled.
	* Makefile.in (libcpp_a_OBJS): Add directives-only.o.
	(libcpp_a_SOURCES): Add directives-only.c.

	gcc/
	* c-ppoutput.c (print_lines_directives_only): New function.
	(scan_translation_unit_directives_only): New function.
	(preprocess_file): Add call to scan_translation_unit_directives_only.
	* c-opts.c (c_common_handle_option): Add OPT_fdirectives_only.
	(sanitize_cpp_opts): Add default flag_dump_macros setting for
	-fdirectives-only.  Add errors for -fdirectives-only conflict with
	-Wunused-macros and -traditional.
	(finish_options): Add builtin macro initialization for
	-fdirectives-only + -fpreprocessed.
	* c.opt (fdirectives-only): New.
	* doc/cppopts.texi (fdirectives-only): New.

	gcc/testsuite/
	* gcc.dg/cpp/counter-2.c: New test.
	* gcc.dg/cpp/counter-3.c: New test.
	* gcc.dg/cpp/dir-only-1.c: New test.
	* gcc.dg/cpp/dir-only-1.h: New file.
	* gcc.dg/cpp/dir-only-2.c: New test.
	* gcc.dg/cpp/dir-only-3.c: New test.
	* gcc.dg/cpp/dir-only-3a.h: New file.
	* gcc.dg/cpp/dir-only-3b.h: New file.
	* gcc.dg/cpp/dir-only-4.c: New test.
	* gcc.dg/cpp/dir-only-5.c: New test.
	* gcc.dg/cpp/dir-only-6.c: New test.

From-SVN: r127066
2007-07-30 18:29:20 +00:00
Michael Meissner 4cd97075ff make alloca call type correct
From-SVN: r123374
2007-03-30 22:40:19 +00:00
Richard Henderson 121de39fc0 directives.c (lex_macro_node_from_str): New.
libcpp/
        * directives.c (lex_macro_node_from_str): New.
        (cpp_push_definition, cpp_pop_definition): New.
        * include/cpplib.h (cpp_push_definition, cpp_pop_definition): Declare.
gcc/
        * c-pragma.c (struct def_pragma_macro_value): New.
        (struct def_pragma_macro): New.
        (pushed_macro_table): New.
        (dpm_hash, dpm_eq): New.
        (handle_pragma_push_macro, handle_pragma_pop_macro): New.
        (init_pragma): Install them.
        * doc/tm.texi (HANDLE_PRAGMA_PUSH_POP_MACRO): New.

Co-Authored-By: Kai Tietz <kai.tietz@onevision.com>

From-SVN: r123370
2007-03-30 14:12:53 -07:00
Tom Tromey ee1c2a100a re PR preprocessor/28227 (valid #ifdef rejected)
libcpp
	PR preprocessor/28227:
	* directives.c (lex_macro_node): Added 'is_def_or_undef'
	argument.
	(do_define): Update.
	(do_undef): Update.
	(do_ifdef): Update.
	(do_ifndef): Update.
gcc/testsuite
	PR preprocessor/28227:
	* gcc.dg/cpp/pr28227.c: New file.

From-SVN: r120731
2007-01-12 19:46:49 +00:00
Tom Tromey 705e2d28a1 re PR preprocessor/28165 (_Pragma GCC system_header broken)
libcpp
	PR preprocessor/28165:
	* internal.h (cpp_in_primary_file): New function.
	* directives.c (do_include_next): Use cpp_in_primary_file.
	(do_pragma_once): Likewise.
	(do_pragma_system_header): Likewise.
gcc/testsuite
	PR preprocessor/28165:
	* gcc.dg/cpp/pr28165.c: New file.

From-SVN: r120441
2007-01-04 15:32:26 +00:00
Jakub Jelinek 9d30f270db re PR preprocessor/29612 (gcc --save-temps does not give "multi-character character constant" error)
PR preprocessor/29612
	* directives.c (do_linemarker): Set pfile->buffer->sysp always, not
	only when new_sysp is non-zero.

	* gcc.dg/cpp/pr29612-1.c: New test.
	* gcc.dg/cpp/pr29612-2.c: New test.

From-SVN: r120257
2006-12-29 09:15:08 +01:00
Jakub Jelinek 1c90c6f9c0 re PR preprocessor/27746 (ICE on openmp code when using _Pragma from macro)
PR preprocessor/27746
	* directives.c (do_pragma): Handle pragma with valid namespace
	and invalid name coming from macro expansion.
	* directives.c (destringize_and_run): Initialize next field in
	context.

	PR c/27747
	PR c++/27748
	* directives.c (destringize_and_run): Set NO_EXPAND on the
	tokens.

	* macro.c (_cpp_backup_tokens): Fix comment typo.
testsuite/
	PR c/27747
	* gcc.dg/cpp/_Pragma6.c: New test.

	PR c++/27748
	* g++.dg/cpp/_Pragma1.C: New test.

	PR preprocessor/27746
	* gcc.dg/gomp/macro-3.c: New test.
	* gcc.dg/gomp/macro-4.c: New test.
	* g++.dg/gomp/macro-3.C: New test.
	* g++.dg/gomp/macro-4.C: New test.

From-SVN: r114519
2006-06-09 23:13:25 +02:00
Richard Henderson bc4071dd66 directives.c (struct pragma_entry): Add is_deferred.
libcpp/
	* directives.c (struct pragma_entry): Add is_deferred.  Add ident
	entry to value union.
	(end_directive): Don't eat the line if in_deferred_pragma.
	(run_directive): Remove pragma hacks.
	(insert_pragma_entry): Remove.
	(new_pragma_entry): New.
	(register_pragma_1): Split out of register_pragma.  Only handle
	the lookup tree and return the new entry.
	(cpp_register_pragma): Fill in the pragma entry here.
	(cpp_register_deferred_pragma): New.
	(register_pragma_internal): New.
	(_cpp_init_internal_pragmas): Use register_pragma_internal.
	(do_pragma): Allow pragma expansion after namespace.  For deferred
	pragmas, don't slurp the line into a string.
	(destringize_and_run): Save tokens for deferred pragmas.
	(cpp_handle_deferred_pragma): Remove.
	* macro.c (builtin_macro): Remove pragma token hack.
	(_cpp_push_token_context): Rename from push_token_context and export.
	* internal.h (struct lexer_state): Add pragma_allow_expansion.
	(_cpp_push_token_context): Declare.
	* lex.c (_cpp_lex_token): Allow _cpp_handle_directive to return
	a token.  Update the line number correctly if so.
	(_cpp_lex_direct): Emit CPP_PRAGMA_EOL tokens.
	(cpp_token_val_index): Return CPP_TOKEN_FLD_PRAGMA for pragmas.
	* include/cpplib.h (PRAGMA_EOL): New.
	(CPP_TOKEN_FLD_PRAGMA): New.
	(struct cpp_token): Add val.pragma.
	(struct cpp_options): Remove defer_pragmas.
	(cpp_handle_deferred_pragma): Remove.
	(cpp_register_deferred_pragma): Declare.

gcc/
	* c-lex.c (c_lex_with_flags) <CPP_PRAGMA>: Smuggle pragma id
	via integer constant.
	(pragma_lex): Remove.
	* c-pch.c (c_common_pch_pragma): Accept the name as an argument,
	rather than parsing it.
	* c-pragma.c (handle_pragma_weak, handle_pragma_redefine_extname,
	handle_pragma_extern_prefix): Add %< %> quotes.
	(registered_pragmas): New.
	(c_register_pragma_1): New.
	(c_register_pragma): Use it.
	(c_register_pragma_with_expansion): Likewise.
	(c_invoke_pragma_handler): New.
	(init_pragma): Use cpp_register_deferred_pragma directly for
	pch_preprocess.
	* c-pragma.h (enum pragma_kind): New.
	(pragma_handler): New.
	(c_invoke_pragma_handler): Declare.
	* c-common.c (c_parse_error): Pretty print CPP_PRAGMA and
	CPP_PRAGMA_EOL.
	* c-common.h (c_common_pch_pragma): Update decl.
	* Makefile.in (c-parser.o): Update dependencies.
	(GTFILES): Add c-pragma.h.
	* c-parser.c (struct c_token): Add pragma_kind.
	(struct c_parser): Add in_pragma.
	(c_lex_one_token): Always initialize keyword and pragma_kind.
	Extract data for CPP_PRAGMA.
	(c_parser_peek_2nd_token): Deny CPP_PRAGMA_EOL.
	(c_parser_consume_token): Don't allow CPP_PRAGMA unless errors.
	Don't allow CPP_PRAGMA_EOL if in_pragma.
	(c_parser_consume_pragma): New.
	(c_parser_skip_until_found): Stop on CPP_PRAGMA_EOL.
	(c_parser_skip_to_end_of_parameter): Likewise.
	(c_parser_skip_to_end_of_block_or_statement): Likewise.
	(c_parser_skip_to_pragma_eol): New.
	(c_parser_external_declaration): Handle CPP_PRAGMA.
	(c_parser_compound_statement_nostart): Likewise.
	(c_parser_statement_after_labels): Likewise.
	(c_parser_pragma): New.
	(pragma_lex): Likewise.
	(c_parser_pragma_pch_preprocess): New.
	(c_parser_new): Merge into ...
	(c_parse_file): ... here.  Call c_parser_pragma_pch_preprocess.

gcc/cp/
	* lex.c (handle_pragma_java_exceptions): Fix whitespace.
	* parser.c (struct cp_token): Add pragma_kind.
	(eof_token): Update to match.
	(struct cp_lexer): Add in_pragma; rearrange next for better packing.
	(cp_parser_initial_pragma): New.
	(cp_lexer_new_main): Use it.  Don't bother clearing
	c_lex_return_raw_strings.
	(cp_lexer_get_preprocessor_token): Always initialize keyword
	and pragma_kind fields.  Handle CPP_PRAGMA.
	(cp_lexer_consume_token): Don't allow CPP_PRAGMA_EOL when 
	in_pragma is set.
	(cp_lexer_handle_pragma): Remove.  Update callers to cp_parser_pragma.
	(cp_lexer_print_token) <CPP_PRAGMA>: Don't print as a string.
	(cp_parser_skip_to_pragma_eol): New.
	(cp_parser_error): Use it.
	(cp_parser_skip_to_closing_parenthesis): Stop at CPP_PRAGMA_EOL;
	rearrange with switch statement.
	(cp_parser_skip_to_end_of_statement): Likewise.
	(cp_parser_skip_to_end_of_block_or_statement): Likewise.
	(cp_parser_skip_to_closing_brace): Likewise.
	(cp_parser_skip_until_found): Likewise.
	(cp_parser_statement): Add in_compound argument; update callers.
	Use it to decide how to handle pragma parsing.
	(cp_parser_labeled_statement): Add in_compound argument; pass
	it on to cp_parser_statement.
	(cp_parser_statement_seq_opt): Stop at CPP_PRAGMA_EOL.
	(cp_parser_declaration_seq_opt): Likewise.
	(cp_parser_parameter_declaration): Likewise.
	(cp_parser_member_specification_opt): Likewise.
	(cp_parser_function_definition_after_decl): Likewise.
	(cp_parser_cache_group): Handle CPP_PRAGMA/CPP_PRAGMA_EOL pairs.
	(cp_parser_pragma): New.
	(pragma_lex): New.

gcc/testsuite/
	* g++.dg/parse/pragma2.C: Update expected error lines.

From-SVN: r109336
2006-01-04 08:33:38 -08:00
Jakub Jelinek d09e893f10 re PR c++/25294 (Bogus "unterminated comment" error from #pragma comment)
PR c++/25294
	* directives.c (do_pragma): If pragma line ends with multi-line
	block comment, end the saved deferred pragma string before that
	comment.  Handle embedded '\0' chars on the pragma line.

	* gcc.dg/pragma-pack-3.c: New test.
	* g++.dg/parse/pragma3.C: New test.

From-SVN: r109201
2006-01-01 00:45:58 +01:00
Ian Lance Taylor cbc43ae091 re PR preprocessor/13726 (cpp -C -dI loses comments on same line as #include directives)
libcpp/
	PR preprocessor/13726
	* directives.c (check_eol_return_comments): New static function.
	(parse_include): Add buf parameter.  Change all callers.
	(do_include_common): If not discard comments, turn on
	save_comments.  Pass collected comments to include callback.
	* include/cpplib.h (struct cpp_callbacks): Add new parameter to
	include callback: cpp_token list.
gcc/
	PR preprocessor/13726
	* c-ppoutput.c (cb_include): Add comments parameter, and print out
	any comments passed in.
gcc/testsuite/
	PR preprocessor/13726
	* gcc.dg/cpp/cmdlne-dI-C.c: New test.
	* gcc.dg/cpp/cmdlne-dI-C.h: New file.

From-SVN: r104951
2005-10-04 18:06:19 +00:00
Kelley Cook 200031d1d5 all files: Update FSF address in copyright headers.
2005-06-29  Kelley Cook  <kcook@gcc.gnu.org>

	* all files: Update FSF address in copyright headers.
	* makeucnid.c (write_copyright): Update outputted FSF address.

From-SVN: r101413
2005-06-29 02:34:39 +00:00
Gabriel Dos Reis c3f829c1a6 configure.ac: Check declarations for asprintf and vasprintf.
* configure.ac: Check declarations for asprintf and vasprintf.
	* config.in: Regenerate.
	* configure: Likewise.

	* charset.c (conversion_loop): Use XRESIZEVEC.
	(convert_no_conversion): Likewise.
	(convert_using_iconv): Likewise.
	(init_iconv_desc): Cast return value of alloca.
	(cpp_host_to_exec_charset): Use XNEWVEC.
	(emit_numeric_escape): Use XRESIZEVEC.
	(cpp_interpret_string): Use XNEWVEC.
	(cpp_interpret_string): Use XRESIZEVEC.
	(_cpp_interpret_identifier): Cast return value of alloca.
	(_cpp_convert_input): Use XNEWVEC and XRESIZEVEC.
	* directives.c (glue_header_name): Use XNEWVEC and XRESIZEVEC.
	(parse_include): Use XNEWVEC.
	(insert_pragma_entry): Rename local variable "new" to
	"new_entry".
	(save_registered_pragmas): Cast return value of xmemdup.
	(destringize_and_run): Same for alloca.
	(parse_assertion): Likewise.
	(do_assert): Cast allocated storage to proper type.
	(cpp_define): Likewise.
	(_cpp_define_builtin): Likewise.
	(cpp_undef): Likewise.
	(handle_assertion): Likewise.
	(cpp_push_buffer): Rename local variable "new" to "new_buffer".
	* expr.c (CPP_UPLUS): Cast value to type cpp_ttype.
	(CPP_UMINUS): Likewise.
	(struct cpp_operator): Rename from struct operator.
	(_cpp_expand_op_stack): Use XRESIZEVEC.
	* files.c (pch_open_file): Use XNEWVEC.
	(pch_open_file): Use XRESIZEVEC.
	(read_file_guts): Use XNEWVEC and XRESIZEVEC.
	(dir_name_of_file): Use XNEWVEC.
	(make_cpp_file): Use XCNEW.
	(make_cpp_dir): Likewise.
	(allocate_file_hash_entries): USE XNEWVEC.
	(cpp_included): Cast return value of htab_find_with_hash.
	(append_file_to_dir): Use XNEWVEC.
	(read_filename_string): Likewise. Use XRESIZEVEC too.
	(read_name_map): Cast return value of alloca.  Use XRESIZEVEC.
	(remap_filename): Use XNEWVEC.
	(struct pchf_entry): Move definition out of struct pchf_data.
	(_cpp_save_file_entries): Use XCNEWVAR.
	(_cpp_read_file_entries): Use XNEWVAR.
	* identifiers.c (alloc_node): Use XOBNEW.
	* init.c (cpp_create_reader): Use XCNEW.
	(cpp_init_builtins): Cast of b->value to enum builtin_type.
	(read_original_directory): Cast return value of alloca.
	* lex.c (add_line_note): Use XRESIZEVEC.
	(warn_about_normalization): Use XNEWVEC.
	(_cpp_lex_direct): Cast node->directive_index to (enum cpp_ttype).
	(new_buff): Use XNEWVEC.
	* line-map.c (linemap_add): Use XRESIZEVEC.
	* macro.c (builtin_macro): Cast return value of alloca.
	(paste_tokens): Likewise.
	(expand_arg): Use XNEWVEC and XRESIZEVEC.
	(_cpp_save_parameter): Use XRESIZEVEC.
	(create_iso_definition): Cast allocated storage to proper type.
	(_cpp_create_definition): Likewise.
	(cpp_macro_definition): Use XRESIZEVEC.
	* makedepend.c (add_clm): Use XNEW.
	(add_dir): Likewise.
	* mkdeps.c (munge): Use XNEWVEC.
	(deps_init): Use XCNEW.
	(deps_add_target): Use XRESIZEVEC.
	(deps_add_default_target): Cast return value of alloca.
	(deps_add_dep): Use XRESIZEVEC.
	(deps_add_vpath): Likewise.  Use XNEWVEC too.
	(deps_restore): Likewise.
	* pch.c (save_idents): Use XNEW and XNEWVEC.
	(cpp_save_state): Use XNEW.
	(count_defs): Cast return value of htab_find.
	(write_defs): Likewise.
	(cpp_write_pch_deps): Use XNEWVEC.
	(collect_ht_nodes): Use XRESIZEVEC.
	(cpp_valid_state): Use XNEWVEC.
	(save_macros): Use XRESIZEVEC.  Cast return value of xmemdup.
	* symtab.c (ht_create): Use XCNEW.
	(ht_lookup_with_hash): Cast return value of obstack_copy0.
	(ht_expand): Use XCNEWVEC.
	* system.h (HAVE_DESIGNATED_INITIALIZERS): False if __cplusplus.
	(bool): Do not define if __cplusplus.

From-SVN: r100295
2005-05-28 15:52:48 +00:00
Zack Weinberg 1ed17cd539 directives.c (#sccs table entry): Mark IN_I, consistent with #ident.
libcpp:
	* directives.c (#sccs table entry): Mark IN_I, consistent with #ident.
	(do_sccs): Delete function definition, #define to do_ident.
	(do_ident): Don't hardwire directive name.
gcc:
	* doc/cpp.texi: Document that #sccs is a synonym for #ident.

From-SVN: r99623
2005-05-12 18:31:38 +00:00
Geoffrey Keating 47e204910a Index: libcpp/ChangeLog
2005-03-12  Geoffrey Keating  <geoffk@apple.com>

	* directives.c (glue_header_name): Update call to cpp_spell_token.
	* internal.h (_cpp_interpret_identifier): New.
	* charset.c (_cpp_interpret_identifier): New.
	(_cpp_valid_ucn): Allow UCN version of '$'.
	* lex.c (lex_identifier): Add extra parameter to indicate if initial
	character was '$' or '\'.  Support identifiers with UCNs.
	(forms_identifier_p): Allow UCNs.
	(_cpp_lex_direct): Pass extra parameter to lex_identifier.
	(utf8_to_ucn): New.
	(cpp_spell_token): Add FORSTRING parameter.  Use it.
	(cpp_token_as_text): Update call to cpp_spell_token.
	(cpp_output_token): Write UCNs back out.
	(stringify_arg): Update call to cpp_spell_token.
	(paste_tokens): Likewise.
	(cpp_macro_definition): Likewise.
	* macro.c (stringify_arg): Likewise.
	(paste_tokens): Likewise.
	(cpp_macro_definition): Likewise.
	* include/cpplib.h: Add parameter to cpp_spell_token.

Index: gcc/ChangeLog
2005-03-12  Geoffrey Keating  <geoffk@apple.com>

	* c-lex.c (c_lex_with_flags): Add parameter to call to
	cpp_spell_token.

Index: gcc/testsuite/ChangeLog
2005-03-12  Geoffrey Keating  <geoffk@apple.com>

	* gcc.dg/ucnid-1.c: New.
	* gcc.dg/ucnid-2.c: New.
	* gcc.dg/ucnid-3.c: New.
	* gcc.dg/ucnid-4.c: New.
	* gcc.dg/ucnid-5.c: New.
	* gcc.dg/ucnid-6.c: New.
	* gcc.dg/cpp/ucnid-1.c: New.
	* gcc.dg/cpp/ucnid-2.c: New.
	* gcc.dg/cpp/ucnid-3.c: New.
	* g++.dg/other/ucnid-1.C: New.

From-SVN: r96333
2005-03-12 10:44:06 +00:00