Commit Graph

124 Commits

Author SHA1 Message Date
Edward Smith-Rowland 7057e6452b Implement C++14 digit separators.
libcpp:

2013-10-31  Edward Smith-Rowland  <3dw4rd@verizon.net>

        Implement C++14 digit separators.
	* include/cpplib.h (cpp_options): Add digit_separators flag.
	* internal.h (DIGIT_SEP(c)): New macro.
	* expr.c (cpp_classify_number): Check improper placement of digit sep;
	(cpp_interpret_integer): Skip over digit separators.
	* init.c (lang_flags): Add digit_separators flag; (lang_defaults): Add
	digit separator flags per language; (cpp_set_lang): Set
	digit_separators
	* lex.c (lex_number): Add digits separator to allowable characters for
	C++14.


gcc/c-family:

2013-10-31  Edward Smith-Rowland  <3dw4rd@verizon.net>

        Implement C++14 digit separators.
	* c-lex.c (interpret_float): Remove digit separators from scratch string
	before building real literal.


gcc/testsuite:

2013-10-31  Edward Smith-Rowland  <3dw4rd@verizon.net>

        Implement C++14 digit separators.
	* g++.dg/cpp1y/digit-sep.C: New.
	* g++.dg/cpp1y/digit-sep-neg.C: New.
	* g++.dg/cpp1y/digit-sep-cxx11-neg.C: New.


libstdc++-v3:

2013-10-31  Edward Smith-Rowland  <3dw4rd@verizon.net>

        Implement C++14 digit separators.
	* include/include/bits/parse_numbers.h: Change struct _Digit<_Base, '`'>
	to struct _Digit<_Base, '\''>.

From-SVN: r204260
2013-10-31 14:01:23 +00:00
Jakub Jelinek 8cf887352b re PR preprocessor/57620 (Phantom terminator confuses raw string literal parsing.)
PR preprocessor/57620
	* lex.c (lex_raw_string): Undo phase1 and phase2 transformations
	between R" and final " rather than only in between R"del( and )del".

	* c-c++-common/raw-string-2.c (s12, u12, U12, L12): Remove.
	(main): Don't test {s,u,U,L}12.
	* c-c++-common/raw-string-13.c: New test.
	* c-c++-common/raw-string-14.c: New test.
	* c-c++-common/raw-string-15.c: New test.
	* c-c++-common/raw-string-16.c: New test.

From-SVN: r201091
2013-07-21 04:28:03 +02:00
Jakub Jelinek d5e48350b4 re PR preprocessor/57824 (Raw string literals not handled correctly in macro arguments or deferred pragmas)
PR preprocessor/57824
	* lex.c (lex_raw_string): Allow reading new-lines if
	in_deferred_pragma or if parsing_args and there is still
	data in the current buffer.

	* c-c++-common/raw-string-17.c: New test.
	* c-c++-common/gomp/pr57824.c: New test.

From-SVN: r200879
2013-07-10 18:52:19 +02:00
Jakub Jelinek c26302d535 c-ppoutput.c (scan_translation_unit): Call account_for_newlines for all CPP_TOKEN_FLD_STR tokens, not just CPP_COMMENT.
* c-ppoutput.c (scan_translation_unit): Call account_for_newlines
	for all CPP_TOKEN_FLD_STR tokens, not just CPP_COMMENT.

	* include/cpplib.h (cpp_token_val_index): Change parameter type to
	const cpp_token *.
	* lex.c (cpp_token_val_index): Likewise.

	* c-c++-common/raw-string-18.c: New test.
	* c-c++-common/raw-string-19.c: New test.

From-SVN: r200878
2013-07-10 18:49:24 +02:00
Jakub Jelinek 87e356bada re PR preprocessor/57757 (CPP extra inserted whitespace needs to be reviewed for C++11 user-defined literals)
PR preprocessor/57757
	* lex.c (cpp_avoid_paste): Avoid pasting CPP_{,W,UTF8}STRING
	or CPP_STRING{16,32} with CPP_NAME or SPELL_LITERAL token that
	starts if a-zA-Z_.

	* g++.dg/cpp/paste1.C: New test.
	* g++.dg/cpp/paste2.C: New test.

From-SVN: r200875
2013-07-10 18:40:49 +02:00
Ed Smith-Rowland c865f9238a lex.c (lex_raw_string(), [...]): Constrain suffixes treated as concatenated literal and macro to just the...
libcpp:

2013-06-28  Ed Smith-Rowland  <3dw4rd@verizon.net>

	* lex.c (lex_raw_string(), lex_string()): Constrain suffixes treated
	as concatenated literal and macro to just the patterns found in
	inttypes.h; (is_macro()): New.


gcc/cp:

2013-06-28  Ed Smith-Rowland  <3dw4rd@verizon.net>

	* cp-tree.h (UDLIT_OP_ANSI_PREFIX): Remove space.
	* parser.c (cp_parser_operator()): Parse user-defined string
	literal as literal operator.


gcc/testsuite:

2013-06-28  Ed Smith-Rowland  <3dw4rd@verizon.net>

	* g++.dg/cpp0x/udlit-nospace-neg.C: Adjust.
	* g++.dg/cpp1y/udlit-enc-prefix-neg.C: New.
	* g++.dg/cpp1y/udlit-userdef-string.C: New.
	* g++.dg/cpp1y/complex_literals.h: New.

From-SVN: r200563
2013-06-29 03:41:58 +00:00
Paolo Carlini 61949153f4 cpplib.h (enum c_lang): Add CLK_GNUCXX1Y and CLK_CXX1Y.
/libcpp
2013-04-24  Paolo Carlini  <paolo.carlini@oracle.com>

	* include/cpplib.h (enum c_lang): Add CLK_GNUCXX1Y and CLK_CXX1Y.
	* init.c (lang_defaults): Add defaults for the latter.
	(cpp_init_builtins): Define __cplusplus as 201300L for the latter.
	* lex.c (_cpp_lex_direct): Update.

/gcc/c-family
2013-04-24  Paolo Carlini  <paolo.carlini@oracle.com>

	* c-opts.c (set_std_cxx11): Use CLK_CXX1Y and CLK_GNUCXX1Y.

/gcc/testsuite
2013-04-24  Paolo Carlini  <paolo.carlini@oracle.com>

	* g++.dg/cpp1y/cplusplus.C: New.

From-SVN: r198261
2013-04-24 19:33:54 +00:00
Jakub Jelinek 1a80db971d configure.ac: Don't define ENABLE_CHECKING whenever --enable-checking is seen...
* configure.ac: Don't define ENABLE_CHECKING whenever
	--enable-checking is seen, instead use similar --enable-checking=yes
	vs. --enable-checking=release default as gcc/ subdir has and
	define ENABLE_CHECKING if ENABLE_CHECKING is defined in gcc/.
	Define ENABLE_VALGRIND_CHECKING if requested.
	* lex.c (new_buff): If ENABLE_VALGRIND_CHECKING, put _cpp_buff
	struct first in the allocated buffer and result->base after it.
	(_cpp_free_buff): If ENABLE_VALGRIND_CHECKING, free buff itself
	instead of buff->base.
	* config.in: Regenerated.
	* configure: Regenerated.

From-SVN: r196333
2013-02-28 10:58:47 +01:00
Ed Smith-Rowland 561f7fc72c re PR c++/55582 ([C++11] Unable to define string user-defined literal without leading underscore.)
gcc/libcpp/

2013-02-13  Ed Smith-Rowland  <3dw4rd@verizon.net>

	PR c++/55582
	* libcpp/lex.c (lex_raw_string): Allow string literal with suffix
	beginning with 's' to be parsed as a C++11 user-defined literal.


gcc/testsuite/

2013-02-13  Ed Smith-Rowland  <3dw4rd@verizon.net>

	PR c++/55582
	* g++.dg/cpp0x/udlit-string-literal.h: New.
	* g++.dg/cpp0x/udlit-string-literal.C: New.

From-SVN: r196041
2013-02-14 02:55:42 +00:00
Richard Sandiford 500f3ed906 Update copyright years in libcpp.
From-SVN: r195162
2013-01-14 18:13:59 +00:00
Paolo Carlini 1582c67762 PR c++/54526 (again)
/libcpp
2013-01-04  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/54526 (again)
	* lex.c (_cpp_lex_direct): In C++11 mode, implement 2.5 p3, bullet 2.

/gcc/cp
2013-01-04  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/54526 (again)
	* parser.c (cp_parser_template_id): Revert core of previous change
	(keep adjusted inform message).

/gcc/testsuite
2013-01-04  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/54526 (again)
	* g++.dg/cpp0x/parse2.C: Extend.
	* g++.old-deja/g++.other/crash28.C: Adjust.

From-SVN: r194909
2013-01-04 15:30:24 +00:00
Tobias Burnus 55e7f90769 files.c (read_file_guts, [...]): Free memory before returning.
2012-10-15  Tobias Burnus  <burnus@net-b.de>

        * files.c (read_file_guts, _cpp_save_file_entries): Free memory
        before returning.
        * lex.c (warn_about_normalization): Ditto.
        * mkdeps.c (deps_save): Ditto.
        * pch.c (cpp_valid_state): Ditto.

From-SVN: r192474
2012-10-15 22:08:57 +02:00
Uros Bizjak d35d1c0fee lex.c (search_line_sse42): Use __builtin_ia32_loaddqu and __builtin_ia32_pcmpestri128 instead of asm.
* lex.c (search_line_sse42): Use __builtin_ia32_loaddqu and
	__builtin_ia32_pcmpestri128 instead of asm.

From-SVN: r188782
2012-06-19 18:28:50 +02:00
Dodji Seketeli 53a103d304 PR bootstrap/53459 - unused local typedef when building on altivec
PR bootstrap/53459
	* lex.c (search_line_fast): Avoid unused local typedefs to simulate
	a static assertion.

From-SVN: r187947
2012-05-29 11:42:39 +02:00
Dodji Seketeli 6de6b1ec5f Revert "PR bootstrap/53459 - unused local typedef when building on altivec"
This reverts commit r187853

From-SVN: r187946
2012-05-29 11:42:28 +02:00
Dodji Seketeli 27c53c0cce PR bootstrap/53459 - unused local typedef when building on altivec
libcpp/

	PR bootstrap/53459
	* lex.c (search_line_fast): Remove unused typedef check_count.

From-SVN: r187853
2012-05-24 23:05:49 +02:00
Dodji Seketeli 112448b448 Don't use C++ style comments in libcpp
I noticed that the file lex.c had C++ style comments, which I believe
is against the coding standards of the project.

Fixed, tested and applied to master as per the obvious rule.

libcpp/

	* lex.c (lex_raw_string): Change C++ style comments into C
	style comments.
	(lex_string): Likewise.

From-SVN: r186946
2012-04-29 18:27:08 +02:00
Ollie Wild 7f5f5f98c5 Add new option, -Wliteral-suffix.
This option, which is enabled by default, causes the preprocessor to warn
when a string or character literal is followed by a ud-suffix which does
not begin with an underscore.  According to [lex.ext]p10, this is
ill-formed.

Also modifies the preprocessor to treat such ill-formed suffixes as separate
preprocessing tokens.  This is consistent with the Clang front end (see
http://llvm.org/viewvc/llvm-project?view=rev&revision=152287), and enables
backwards compatibility with code that uses formatting macros from
<inttypes.h>, as in the following code block:

  int main() {
    int64_t i64 = 123;
    printf("My int64: %"PRId64"\n", i64);
  }

Google ref b/6377711.

2012-04-27   Ollie Wild  <aaw@google.com>

	PR c++/52538
	* gcc/c-family/c-common.c: Add CPP_W_LITERAL_SUFFIX mapping.
	* gcc/c-family/c-opts.c (c_common_handle_option): Handle
	OPT_Wliteral_suffix.
	* gcc/c-family/c.opt: Add Wliteral-suffix.
	* gcc/doc/invoke.texi (Wliteral-suffix): Document new option.
	* gcc/testsuite/g++.dg/cpp0x/Wliteral-suffix.c: New test.
	* libcpp/include/cpplib.h (struct cpp_options): Add new field,
	warn_literal_suffix.
	(CPP_W_LITERAL_SUFFIX): New enum.
	* libcpp/init.c (cpp_create_reader): Default initialization of
	warn_literal_suffix.
	* libcpp/lex.c (lex_raw_string): Treat user-defined literals which
	don't begin with '_' as separate tokens and produce a warning.
	(lex_string): Ditto.

From-SVN: r186909
2012-04-27 14:29:32 +00:00
Richard Earnshaw e75b54a2d9 * lex.c (search_line_fast): Provide Neon-optimized version for ARM.
From-SVN: r185702
2012-03-22 17:54:55 +00:00
Rainer Orth 7888f2660e Remove obsolete Solaris 8 support
libstdc++-v3:
	* config/os/solaris/solaris2.8: Rename to ...
	* config/os/solaris/solaris2.9: ... this.
	* config/abi/post/solaris2.8: Rename to ...
	* config/abi/post/solaris2.9: ... this.
	* configure.host (os_include_dir): Remove solaris2.8.
	Reflect renaming.
	(abi_baseline_pair): Remove *-*-solaris2.8.
	Reflect renaming.

	* configure.ac (GLIBCXX_CHECK_MATH_PROTO): Remove
	(GLIBCXX_CHECK_STDLIB_PROTO): Remove.
	* acinclude.m4 (GLIBCXX_CHECK_MATH_PROTO): Remove
	(GLIBCXX_CHECK_STDLIB_PROTO): Remove.
	(GLIBCXX_CHECK_GTHREADS): Remove Solaris 8 handling.
	* crossconfig.m4 (GLIBCXX_CROSSCONFIG): Remove *-solaris2.8
	handling.
	* configure: Regenerate.
	* config.h.in: Regenerate.

	* config/os/solaris/solaris2.9/os_defines.h
	(__CORRECT_ISO_CPP_MATH_H_PROTO): Define.
	(__CORRECT_ISO_CPP_STDLIB_H_PROTO): Define.
	* include/c_global/cmath: Rename __CORRECT_ISO_CPP_MATH_H_PROTO1
	to __CORRECT_ISO_CPP_MATH_H_PROTO.
	[!__CORRECT_ISO_CPP_MATH_H_PROTO2]: Remove.
	* include/tr1/cmath: Rename __CORRECT_ISO_CPP_MATH_H_PROTO1 to
	__CORRECT_ISO_CPP_MATH_H_PROTO.

	* doc/xml/manual/configure.xml (Configure, --enable-libstdcxx-threads):
	Remove Solaris 8 reference.

	* testsuite/27_io/basic_istream/extractors_arithmetic/char/12.cc:
	Don't xfail on *-*-solaris2.8.
	* testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/12.cc:
	Likewise.
	* testsuite/ext/enc_filebuf/char/13598.cc: Don't xfail on
	*-*-solaris2.8.

	libjava:
	* configure.ac (THREADLIBS): Remove *-*-solaris2.8 handling.
	* configure: Regenerate.

	libgcc:
	* config/i386/sol2-unwind.h (x86_fallback_frame_state): Remove
	Solaris 8 handling.
	* config/sparc/sol2-unwind.h (sparc64_is_sighandler): Remove
	Solaris 8 handling.
	(sparc_is_sighandler): Likewise.

	libcpp:
	* lex.c: Remove Solaris 8 reference.

	gcc/testsuite:
	* g++.dg/warn/miss-format-1.C: Remove *-*-solaris2.8 handling.
	* gcc.dg/c99-stdint-6.c: Likewise.
	* gcc.dg/lto/20090210_0.c: Likewise.
	* gcc.dg/pr28796-2.c: Don't skip on sparc*-sun-solaris2.8.
	* gcc.dg/pragma-init-fini.c: Don't skip on i?86-*-solaris2.8.
	* gcc.dg/pragma-init-fini-2.c: Likewise.
	* gcc.dg/torture/pr47917.c: Remove *-*-solaris2.8 handling.
	* gcc.target/i386/pr22076.c: Remove i?86-*-solaris2.8 handling.
	* gcc.target/i386/pr22152.c: Likewise.
	* gcc.target/i386/vect8-ret.c: Likewise.
	* lib/target-supports.exp (add_options_for_tls): Remove Solaris 8
	handling.

	gcc:
	* config.gcc (enable_obsolete): Remove *-*-solaris2.8*.
	(*-*-solaris2.[0-8], *-*-solaris2.[0-8].*): Mark unsupported.
	(i[34567]86-*-solaris2*, x86_64-*-solaris2.1[0-9]*): Remove
	Solaris 8 support.
	* configure.ac (gcc_cv_ld_hidden): Remove *-*-solaris2.8*.
	(ld_tls_support): Remove Solaris 8 references.
	(lwp_dir, lwp_spec): Remove support for alternate thread library.
	* acinclude.m4 (gcc_cv_initfini_array): Remove *-*-solaris2.*
	tests.
	* configure: Regenerate.
	* config.in: Regenerate.

	* config/sol2.h (LINK_SPEC): Remove LIB_THREAD_LDFLAGS_SPEC.
	* config/i386/sol2.h: Remove Solaris 8 references.

	* doc/install.texi (Specific, i?86-*-solaris2.[89]): Rename to ...
	(i?86-*-solaris2.9): ... this.
	Remove Solaris 8 references.
	(Specific, *-*-solaris2*): Document Solaris 8 removal.
	Remove Solaris 8 references.

	fixincludes:
	* inclhack.def (math_exception): Remove duplicate.
	(solaris_cond_init): Remove.
	(solaris_sys_va_list): Remove Solaris 8 support.
	* fixincl.x: Regenerate.
	* tests/base/pthread.h [SOLARIS_COND_INIT_CHECK]: Remove.

From-SVN: r185392
2012-03-14 17:08:03 +00:00
Jakub Jelinek b0c084b712 re PR bootstrap/50237 (bootstrap comparison failure for libcpp/lex.o)
PR bootstrap/50237
	* internal.h (_cpp_init_lexer): New prototype.
	* init.c (init_library): Call it.
	* lex.c (init_vectorized_lexer): Remove constructor attribute,
	add inline keyword.
	(HAVE_init_vectorized_lexer): Define.
	(_cpp_init_lexer): New function.

From-SVN: r182090
2011-12-07 23:05:59 +01:00
Ed Smith-Rowland 3ce4f9e4d2 Implement C++11 user-defined literals.
libcpp/
	* expr.c: (cpp_interpret_float_suffix, cpp_interpret_int_suffix,
	cpp_userdef_string_remove_type, cpp_userdef_string_add_type,
	cpp_userdef_char_remove_type, cpp_userdef_char_add_type,
	cpp_userdef_string_p, cpp_userdef_char_p, cpp_get_userdef_suffix): New.
	(cpp_classify_number): Classify unrecognized tokens as user-defined
	literals.
	* include/cpplib.h: Add new tokens for user-defined literals.
	* init.c: Add new preprocessor flag (cxx11).
	* lex.c: (lex_string, lex_raw_string): Handle user-defined literals
	including concatenation and promotion with suffixes.
c-family/
	* c-common.c (build_userdef_literal): New.
	* c-common.def: New tree code.
	* c-common.h (tree_userdef_literal): New tree struct and accessors.
	* c-lex.c (interpret_float): Add suffix parm.
	(c_lex_with_flags): Build literal tokens.
cp/
	* cp-objcp-common.c: (cp_tree_size) Return size of USERDEF_LITERAL tree.
	* cp-tree.h: (UDLIT_OP_*, UDLIT_OPER_P): Literal operator
	name tools. New tree code for user-defined literals.
	* cxx-pretty-print.h: (pp_cxx_userdef_literal) New.
	* cxx-pretty-print.c: (pp_cxx_userdef_literal) New.
	(pp_cxx_primary_expression, pp_cxx_expression): Use it.
	* decl.c: (cp_tree_node_structure): Return new tree code.
	(duplicate_decls): Check for raw vs. template operator conflicts.
	(grokfndecl, grokdeclarator): New checks for literal operators.
	* error.c: (dump_expr): Warn about user-defined literals
	in C++98 mode. (dump_function_name): Pretty printing.
	* mangle.c: (write_literal_operator_name): New.
	(write_unqualified_id, write_unqualified_name): Use it.
	* parser.c: (cp_parser_operator): Handle operator"".
	(cp_parser_userdef_char_literal, cp_parser_userdef_numeric_literal,
	cp_parser_userdef_string_literal): New.
	(cp_parser_primary_expression): Handle new user-defined literal tokens
	with new functions.
	* semantics.c: (potential_constant_expression_1): Add
	user-defined literals.
	* typeck.c (check_raw_literal_operator,
	check_literal_operator_args): New.

From-SVN: r180536
2011-10-26 15:30:59 -04:00
Dodji Seketeli ad2305adb4 Fix cpp_peek_token behaviour (PR bootstrap/50778)
libcpp/

	* include/internal.h (_cpp_remaining_tokens_num_in_context): Take the
	context to act upon.
	* lex.c (_cpp_remaining_tokens_num_in_context): Likewise.  Update
	comment.
	(cpp_token_from_context_at): Likewise.
	(cpp_peek_token): Use the context to peek tokens from.

From-SVN: r180328
2011-10-22 19:49:18 +02:00
Dodji Seketeli cbbcf65511 Fix thinko in _cpp_remaining_tokens_num_in_context
libcpp/

	* lex.c (_cpp_remaining_tokens_num_in_context): Fix computation of
	number of tokens.

From-SVN: r180239
2011-10-20 10:49:29 +02:00
Tom Tromey 92582b753e Generate virtual locations for tokens
This second instalment uses the infrastructure of the previous patch
to allocate a macro map for each macro expansion and assign a virtual
location to each token resulting from the expansion.

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

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

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

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

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

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

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

From-SVN: r180082
2011-10-17 11:59:12 +02:00
Gabriel Charette e3dfef44ef Add ability to force lexed tokens' source_locations.
Use it to force BUILTINS_LOCATION when declaring builtins instead of creating a <built-in> entry in the line_table which is wrong.

	* c-opts.c (c_finish_options): Force BUILTINS_LOCATION for tokens
	defined in cpp_init_builtins and c_cpp_builtins.

	gcc/fortran/ChangeLog
	* cpp.c (gfc_cpp_init): Force BUILTINS_LOCATION for tokens
	defined in cpp_define_builtins.

	libcpp/ChangeLog
	* init.c (cpp_create_reader): Inititalize forced_token_location_p.
	* internal.h (struct cpp_reader): Add field forced_token_location_p.
	* lex.c (_cpp_lex_direct): Use forced_token_location_p.
	(cpp_force_token_locations): New.
	(cpp_stop_forcing_token_locations): New.

From-SVN: r177973
2011-08-22 20:41:07 +00:00
Joseph Myers a48e3dd10e c1x-uni-string-1.c, [...]: New tests.
gcc/testsuite:
	* gcc.dg/c1x-uni-string-1.c, gcc.dg/c1x-uni-string-2.c: New tests.

libcpp:
	* include/cpplib.h (struct cpp_options): Add rliterals.
	* init.c  (struct lang_flags, lang_defaults): Add rliterals.
	(cpp_set_lang): Set rliterals option.
	(cpp_init_builtins): Define __STDC_UTF_16__ and __STDC_UTF_32__.
	* lex.c (_cpp_lex_direct): Only accept raw strings if rliterals.

From-SVN: r177868
2011-08-18 16:13:49 +01:00
Gabriel Charette 3f6ced102d LINEMAP_POSITION_FOR_COLUMN had the exact same effect as linemap_position_for_column...
LINEMAP_POSITION_FOR_COLUMN had the exact same effect as
linemap_position_for_column, removed it and updated users
to use linemap_position_for_column instead

        libcpp/ChangeLog
	* include/line-map.h (LINEMAP_POSITION_FOR_COLUMN): Remove.
	Update all users to use linemap_position_for_column instead.

        gcc/go/ChangeLog
	* gofrontend/lex.cc (Lex::location): Update to use
	linemap_position_for_column instead.
        (Lex::earlier_location): Likewise.

From-SVN: r177768
2011-08-15 20:35:58 +00:00
Jason Merrill 8787a05aaa re PR c++/45399 ([C++0x] Warning for \0 in raw strings)
PR c++/45399
	* lex.c (lex_raw_string): Don't check for embedded NUL.

From-SVN: r175121
2011-06-16 18:09:12 -04:00
Uros Bizjak 5e70c0b572 * lex.c (init_vectorized_lexer): Fix comparison of masked value.
From-SVN: r174037
2011-05-22 21:04:54 +02:00
Uros Bizjak ef230b3836 re PR bootstrap/49104 (bootstrap failure on AMD K6-2 with illegal instruction (cmove) in stage2)
PR target/49104
	* config/i386/cpuid.h (bit_MMXEXT): New define.

libcpp/ChangeLog:

2011-05-22  Uros Bizjak  <ubizjak@gmail.com>

	PR target/49104
	* lex.c (init_vectorized_lexer): Do not set "minimum" when __3dNOW_A__
	is defined.  Check bit_MMXEXT and bit_CMOV to use search_line_mmx.

From-SVN: r174032
2011-05-22 20:53:32 +02:00
Jakub Jelinek 6cfae07011 re PR preprocessor/48740 (Raw C++0x strings and trigraphs mix badly)
PR preprocessor/48740
	* lex.c (lex_raw_string): When raw string ends with
	??) followed by raw prefix and ", ensure it is preprocessed
	with ??) rather than ??].

	* c-c++-common/raw-string-11.c: New test.

From-SVN: r172903
2011-04-24 01:32:09 +02:00
Richard Henderson 01956319b6 re PR bootstrap/45381 (Bootstrap failure for powerpc-apple-darwin9: error: AltiVec argument passed to unprototyped function)
PR bootstrap/45381
* lex.c [ALTIVEC] (search_line_fast): Require gcc version 4.5.

From-SVN: r171165
2011-03-18 13:20:35 -07:00
Kai Tietz 651a20b54b re PR preprocessor/17349 (// comments cause weird behaviour with options -E -C)
2010-11-16  Kai Tietz  <kai.tietz@onevision.com>

        PR preprocessor/17349
        * lex.c (save_comment): Handle in argument passing c++
        comments special.

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

        PR preprocessor/17349
        * gcc.dg/cpp/cmdlne-C3.c: New.

From-SVN: r166817
2010-11-16 20:50:17 +01:00
Richard Henderson 6f173e52cb re PR bootstrap/45376 (no such instruction: `pcmpestri $0,(%rdi),%xmm0')
PR bootstrap/45376
        * configure.ac (HAVE_SSE4): New check.
        * configure, config.in: Rebuild.
        * lex.c (search_line_sse42): Omit if !HAVE_SSE4.

From-SVN: r163528
2010-08-24 14:08:05 -07:00
Rainer Orth 789d73cb17 lex.c: Disable init_vectorized_lexer etc.
* lex.c [__sun__ && __svr4__]: Disable init_vectorized_lexer
	etc. on Solaris 2/x86.

From-SVN: r163522
2010-08-24 17:23:35 +00:00
Richard Henderson 246a2fcb5e Vectorize fast path of _cpp_clean_line.
* configure.ac (AC_C_BIGENDIAN, AC_TYPE_UINTPTR_T): New tests.
	(ssize_t): Check via AC_TYPE_SSIZE_T instead of AC_CHECK_TYPE.
	(ptrdiff_t): Check via AC_CHECK_TYPE.
	* config.in, configure: Rebuild.
	* system.h: Include stdint.h, if available.
	* lex.c (WORDS_BIGENDIAN): Provide default.
	(acc_char_mask_misalign, acc_char_replicate, acc_char_cmp,
	acc_char_index, search_line_acc_char, repl_chars, search_line_mmx,
	search_line_sse2, search_line_sse42, init_vectorized_lexer,
	search_line_fast): New.
	(_cpp_clean_line): Use search_line_fast.  Restructure the fast
	loop to make it clear when we're leaving the loop.  Stay in the
	fast loop for non-trigraph '?'.

Co-Authored-By: Andi Kleen <ak@linux.intel.com>
Co-Authored-By: David S. Miller <davem@davemloft.net>

From-SVN: r163446
2010-08-21 12:05:40 -07: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
Jakub Jelinek d947ada0a1 re PR preprocessor/43642 (FAIL: c-c++-common/raw-string-1.c)
PR preprocessor/43642
	* lex.c (lex_raw_string): Change type of TYPE variable to
	unsigned char.

From-SVN: r157979
2010-04-06 09:02:40 +02:00
Jason Merrill 00a81b8b9d More N3077 raw string changes
More N3077 raw string changes
	* charset.c (cpp_interpret_string): Don't transform UCNs in raw
	strings.
	* lex.c (bufring_append): Split out from...
	(lex_raw_string): ...here.  Undo trigraph and line splicing
	transformations.  Do process line notes in multi-line literals.
	(_cpp_process_line_notes): Ignore notes that were already handled.

From-SVN: r157804
2010-03-29 16:07:29 -04:00
Jason Merrill 521506258f Some raw string changes from N3077
Some raw string changes from N3077
	* charset.c (cpp_interpret_string): Change inner delimiters to ().
	* lex.c (lex_raw_string): Likewise.  Also disallow '\' in delimiter.

From-SVN: r157797
2010-03-29 11:00:43 -04: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
Ian Lance Taylor 3d8b2a98ca cpplib.h (struct cpp_options): Add warn_cxx_operator_names field.
libcpp/:
	* include/cpplib.h (struct cpp_options): Add
	warn_cxx_operator_names field.
	(NODE_WARN_OPERATOR): Define.
	(struct cpp_hashnode): Increase flags field to 10 bits, decrease
	type to 6 bits.
	* init.c (mark_named_operators): Add flags parameter.
	(cpp_post_options): Pick flags value to pass to
	mark_named_operators.
	* lex.c (lex_identifier): If NODE_WARN_OPERATOR is set, warn that
	identifier is an operator name in C++.
gcc/:
	* fold-const.c (fold_unary): Rename local variable and to
	and_expr.
	* c-opts.c (c_common_handle_option): For -Wc++-compat set
	cpp_opts->warn_cxx_operator_names.
gcc/testsuite/:
	* gcc.dg/Wcxx-compat-13.c: New testcase.

From-SVN: r148438
2009-06-12 19:43:25 +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
Manuel López-Ibáñez cfc9353275 re PR c++/14875 (When using 'or' keyword, the error message speaks of a '||' token)
2009-04-22  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

	PR c++/14875
	* c-common.c (c_parse_error): Take a token_flags parameter.
	Use token_type for the token type instead.
	Pass token_flags to cpp_type2name.
	* c-common.h (c_parse_error): Update declaration.
	* c-parser.c (c_parser_error): Pass 0 as token flags.
libcpp/
	* lex.c (cpp_type2name): Take a flags parameter. Call
	cpp_named_operator2name for named operators and cpp_digraph2name
	for digraphs.
	(cpp_digraph2name): New.
	(cpp_spell_token): Use it.
	(cpp_output_token): Likewise.
	* include/cpplib.h (cpp_type2name): Update declaration.
	* init.c (cpp_named_operator2name): New.
	* internal.h (cpp_named_operator2name): Declare.
cp/	
	* parser.c (cp_parser_error): Pass token->flags to c_parse_error.
testsuite/
	* g++.dg/parse/parser-pr14875.C: New.
	* g++.dg/parse/parser-pr14875-2.C: New.
	* g++.dg/parse/error6.C: Update match string.

From-SVN: r146589
2009-04-22 15:32:18 +00:00
Joseph Myers aa50850225 re PR preprocessor/20078 (Gcc doesn't complain about non-benign macro definitions)
libcpp:
	PR preprocessor/20078
	* include/cpp-id-data.h (struct cpp_macro): Add extra_tokens
	field.
	* include/cpplib.h (SP_DIGRAPH, SP_PREV_WHITE): Define.
	(struct cpp_token): Change flags to unsigned short.
	* lex.c (_cpp_lex_direct): Initialize arg_no for CPP_PASTE tokens.
	(_cpp_equiv_tokens): Check arg_no for CPP_PASTE tokens.
	(cpp_token_val_index): Return CPP_TOKEN_FLD_ARG_NO for CPP_PASTE
	tokens.
	* macro.c (macro_real_token_count): New.
	(enter_macro_context, replace_args): Use macro_real_token_count.
	(create_iso_definition): Record whitespace surrounding and digraph
	spelling of # and ## tokens using SP_PREV_WHITE and SP_DIGRAPH.
	Set extra_tokens and save CPP_PASTE tokens with arg_no set for
	multiple consecutive ## tokens.
	(_cpp_create_definition): Initialize extra_tokens.
	(cpp_macro_definition): Use macro_real_token_count.

gcc/testsuite:
	* gcc.dg/cpp/paste16.c, gcc.dg/cpp/redef4.c: New tests.

From-SVN: r146352
2009-04-19 18:10:56 +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 4bb09c26bc lex.c (lex_string): Return a CPP_LESS token for missing '>' in a header name.
libcpp:
	* lex.c (lex_string): Return a CPP_LESS token for missing '>' in a
	header name.
	(_cpp_lex_direct): Handle this.

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

From-SVN: r144361
2009-02-21 21:25:39 +00:00
Joseph Myers cc95528267 lex.c (cpp_token_len): Use 6 as default length.
libcpp:
	* lex.c (cpp_token_len): Use 6 as default length.

gcc/testsuite:
	* g++.dg/cpp/stringop-1.C: New test.

From-SVN: r142275
2008-11-29 12:21:10 +00:00
Matthew Gingell 631d0d3610 cpplib.h (cpp_comments, [...]): New structs.
2008-10-05  Matthew Gingell  <gingell@adacore.com>
	    Arnaud Charlet  <charlet@adacore.com>

	* include/cpplib.h (cpp_comments, cpp_comment_table): New structs.
	(cpp_get_comments): New function.
	* internal.h (struct cpp_reader): Add comments field.
	* init.c (cpp_destroy): Free comments.
	* lex.c (store_comment, cpp_get_comments): New functions.
	(comments): New struct.
	(save_comment): Store comments in comments struct.

Co-Authored-By: Arnaud Charlet <charlet@adacore.com>

From-SVN: r140883
2008-10-05 14:35:36 +02: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
Ben Elliston 5950c3c9a7 cpplib.h (NODE_CONDITIONAL): New.
libcpp/
	* include/cpplib.h (NODE_CONDITIONAL): New.
	(struct cpp_callbacks): New macro_to_expand field.
	(struct cpp_hashnode): Adjust size of flags and type fields.
	(cpp_peek_token): Prototype.
	* lex.c (cpp_peek_token): New function.
	(_cpp_temp_token): Protect pre-existing lookaheads.
	* macro.c (cpp_get_token): Expand any conditional macros.
	(_cpp_backup_tokens_direct): New.
	(_cpp_backup_tokens): Call _cpp_backup_tokens_direct.
	(warn_of_redefinition): Silently allow redefined conditional
	macros.
	(_cpp_create_definition): Remove the conditional flag when a user
	defines one of the conditional macros.
	* internal.h (_cpp_backup_tokens_direct): New prototype.

gcc/
	* c-common.h (C_CPP_HASHNODE): New macro.
	* coretypes.h (struct cpp_token): Forward declare.
	* doc/extend.texi (PowerPC AltiVec Built-in Functions): Document
	the context-sensitive keyword method.
	* config/rs6000/rs6000-c.c (__vector_keyword, vector_keyword,
	__pixel_keyword, pixel_keyword, __bool_keyword, bool_keyword,
	expand_bool_pixel): New.
	(altivec_categorize_keyword): New function.
	(init_vector_keywords): New function.
	(rs6000_macro_to_expand): Likewise.
	(rs6000_cpu_cpp_builtins): Enable context-sensitive macros if not
	compiling an ISO C dialect.

gcc/testsuite/
	* gcc.target/powerpc/altivec-macros.c: New test.
	* gcc.target/powerpc/altviec-26.c: Likewise.
	* gcc.dg/vmx/1b-06.c: Remove bool variable.
	* gcc.dg/vmx/1b-07.c: Likewise.
	* gcc.dg/vmx/1b-06-ansi.c: New test for the pre-define method.
	* gcc.dg/vmx/1b-07-ansi.c: Likewise.

From-SVN: r137775
2008-07-14 15:09:48 +10: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
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
Tom Tromey 2bf41bf05d traditional.c (lex_identifier): Use CPP_HASHNODE.
* traditional.c (lex_identifier): Use CPP_HASHNODE.
	* lex.c (lex_identifier): Use CPP_HASHNODE.
	* include/line-map.h (LINEMAP_POSITION_FOR_COLUMN): Wrap in
	do-while.
	* identifiers.c (alloc_node): Change return type.
	(_cpp_init_hashtable): Don't cast 'alloc_node'.
	(proxy_assertion_broken): New declaration.
	(cpp_forall_identifiers): Move comment.
	* line-map.c (linemap_add): Comment fix.
	(linemap_line_start): Indentation fix.

From-SVN: r132467
2008-02-20 02:16:43 +00:00
Dave Korn ed0e74e0a6 re PR preprocessor/14331 (please add option to suppress warning message "no newline at end of file")
2007-05-31  Dave Korn  <dave.korn@artimi.com>

        PR preprocessor/14331
        * lex.c (_cpp_get_fresh_line):  Don't warn if no newline at EOF.

From-SVN: r125212
2007-05-31 02:06:48 +00:00
Tom Tromey ee380365ef re PR preprocessor/29966 (crash in cc1 with backtrace from free())
PR preprocessor/29966:
	* macro.c (lex_expansion_token): Save and restore cpp_reader's
	cur_token.
	(_cpp_create_definition): Don't restore cur_token here.
	* lex.c (_cpp_lex_token): Added assertion.

From-SVN: r121340
2007-01-30 15:46:01 +00:00
Ian Lance Taylor 7af45bd465 lex.c (_cpp_clean_line): Add uses of __builtin_expect.
* lex.c (_cpp_clean_line): Add uses of __builtin_expect.  Don't
	look backward at the end of the line unless we saw a backslash.

From-SVN: r120263
2006-12-29 15:43:55 +00:00
Joseph Myers c663e30103 re PR c/28768 (Preprocessor doesn't parse tokens correctly?)
libcpp:
	PR c/28768
	PR preprocessor/14634
	* lex.c (lex_string): Pedwarn for unterminated literals.

libgomp:
	* configure.ac (HAVE_CLOCK_GETTIME): Add missing second argument
	to AC_DEFINE.
	* configure: Regenerate.

gcc/testsuite:
	* gcc.dg/cpp/include2.c, gcc.dg/cpp/macspace1.c,
	gcc.dg/cpp/macspace2.c, gcc.dg/cpp/multiline.c,
	gcc.dg/cpp/trad/literals-2.c: Update expected diagnostics.

From-SVN: r116915
2006-09-13 02:04:18 +01:00
Steve Ellcey b52dbbf865 re PR c++/28288 (ICE with min/max operator)
PR c++/28288
	PR c++/14556
	* operators.def: Remove <?, ?>, <?=, and >?= operators.
	* parser.c: Remove CPP_MIN, CPP_MAX, CPP_MIN_EQ, and CPP_MAX_EQ.
	(cp_parser_warn_min_max): Remove.
	* include/cpplib.h: Remove <?, >?, <?=, and >?= tokens.
	(CPP_LAST_EQ): Change.
	(CPP_LAST_PUNCTUATOR): Change.
	* expr.c (cpp_operator): Remove MIN and MAX.
	(reduce): Remove CPP_MIN and CPP_MAX.
	(num_binary_op): Ditto.
	* lex.c (_cpp_lex_direct): Ditto.
	(cpp_avoid_paste): Remove ? as legal symbol after > or <.

From-SVN: r116140
2006-08-14 23:13:54 +00: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
Joseph Myers af15a2fed7 c.opt (fextended-identifiers): New.
gcc:
	* c.opt (fextended-identifiers): New.
	* c-opts.c (c_common_handle_option): Handle
	-fextended-identifiers.
	* doc/cpp.texi: Update documentation of extended identifiers.
	* doc/cppopts.texi (-fextended-identifiers): Document.

gcc/testsuite:
	* g++.dg/cpp/ucnid-1.C, g++.dg/cpp/normalize-1.C,
	g++.dg/other/ucnid-1.C, gcc.dg/cpp/normalize-1.c,
	gcc.dg/cpp/normalize-2.c, gcc.dg/cpp/normalize-3.c,
	gcc.dg/cpp/normalize-4.c, gcc.dg/cpp/ucnid-1.c,
	gcc.dg/cpp/ucnid-2.c, gcc.dg/cpp/ucnid-3.c, gcc.dg/cpp/ucnid-4.c,
	gcc.dg/cpp/ucnid-5.c, gcc.dg/cpp/ucnid-7.c,gcc.dg/ucnid-1.c,
	gcc.dg/ucnid-2.c, gcc.dg/ucnid-3.c, gcc.dg/ucnid-4.c,
	gcc.dg/ucnid-5.c, gcc.dg/ucnid-6.c: Add -fextended-identifiers.
	* gcc.dg/cpp/ucnid-8.c: New test.

libcpp:
	* include/cpplib.h (struct cpp_options): Add extended_identifiers.
	* init.c (struct lang_flags, lang_defaults): Add
	extended_identifiers.
	(cpp_set_lang): Use it.
	* lex.c (forms_identifier_p): Check extended_identifiers.

From-SVN: r104462
2005-09-20 21:31:37 +01: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
Andreas Jaeger cbada204b4 lex.c (warn_about_normalization): Cast field width to int to avoid warning.
* lex.c (warn_about_normalization): Cast field width to int to
	avoid warning.

From-SVN: r97126
2005-03-28 08:55:47 +02:00
Geoffrey Keating 6baba9bb58 Index: libcpp/ChangeLog
2005-03-14  Geoffrey Keating  <geoffk@apple.com>

	* lex.c (forms_identifier_p): Disable UCNs in C89 mode.

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

	* gcc.dg/cpp/ucnid-6.c: New.

From-SVN: r96475
2005-03-15 09:55:41 +00:00
Geoffrey Keating 50668cf626 Index: gcc/ChangeLog
2005-03-14  Geoffrey Keating  <geoffk@apple.com>

	* doc/cppopts.texi (-fexec-charset): Add concept index entry.
	(-fwide-exec-charset): Likewise.
	(-finput-charset): Likewise.
	* doc/invoke.texi (Warning Options): Document -Wnormalized=.
	* c-opts.c (c_common_handle_option): Handle -Wnormalized=.
	* c.opt (Wnormalized): New.

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

	* init.c (cpp_create_reader): Default warn_normalize to normalized_C.
	* charset.c: Update for new format of ucnid.h.
	(ucn_valid_in_identifier): Update for new format of ucnid.h.
	Add NST parameter, and update it; update callers.
	(cpp_valid_ucn): Add NST parameter, update callers.  Replace abort
	with cpp_error.
	(convert_ucn): Pass normalize_state to cpp_valid_ucn.
	* internal.h (struct normalize_state): New.
	(INITIAL_NORMALIZE_STATE): New.
	(NORMALIZE_STATE_RESULT): New.
	(NORMALIZE_STATE_UPDATE_IDNUM): New.
	(_cpp_valid_ucn): New.
	* lex.c (warn_about_normalization): New.
	(forms_identifier_p): Add normalize_state parameter, update callers.
	(lex_identifier): Add normalize_state parameter, update callers.  Keep
	the state current.
	(lex_number): Likewise.
	(_cpp_lex_direct): Pass normalize_state to subroutines.  Check
	it with warn_about_normalization.
	* makeucnid.c: New.
	* ucnid.h: Replace.
	* ucnid.pl: Remove.
	* ucnid.tab: Make appropriate for input to makeucnid.c.  Remove
	comments about obsolete version of C++.
	* include/cpplib.h (enum cpp_normalize_level): New.
	(struct cpp_options): Add warn_normalize field.

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

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

From-SVN: r96459
2005-03-15 00:36:33 +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
Zack Weinberg 21b11495d7 cpplib.h (TTYPE_TABLE): Remove CPP_ and SPELL_ prefixes throughout.
2004-09-09  Matt Austern  <austern@apple.com>
	    Zack Weinberg  <zack@codesourcery.com>

	* include/cpplib.h (TTYPE_TABLE): Remove CPP_ and SPELL_
	prefixes throughout.  Add entry for PRAGMA.  Remove
	unnecessary "= 0" from EQ.
	(enum cpp_ttype): Adjust OP and TK definitions to restore
	prefixes, via token-paste.
	(CPP_LAST_EQ, CPP_FIRST_DIGRAPH, CPP_LAST_PUNCTUATOR, CPP_LAST_CPP_OP):
	Change from #defines to additional cpp_ttype enumerators.
	(struct cpp_options): Add defer_pragmas.
	(cpp_handle_deferred_pragma): Prototype new interface.

	* internal.h (struct cpp_reader): Add directive_result.
	* directives.c (struct pragma_entry): Add is_internal field;
	give boolean fields type bool.
	(start_directive): Initialize pfile->directive_result.type.
	(_cpp_do__Pragma): Likewise.
	(run_directive): Do not crash if pfile->buffer->prev is NULL.
	(insert_pragma_entry): Add 'internal' argument; set new->is_internal
	from it.
	(register_pragma): New static function, bulk of former
	cpp_register_pragma here; add 'internal' argument, pass along
	to insert_pragma_entry.
	(cpp_register_pragma): Now a wrapper around register_pragma which
	always passes false for 'internal' argument.
	(_cpp_init_internal_pragmas): Call register_pragma directly, passing
	true for 'internal'.
	(do_pragma): If CPP_OPTION (pfile, defer_pragmas) and this isn't
	an internal pragma, save text till the end of the line as a CPP_PRAGMA
	token instead of executing the pragma.
	(cpp_handle_deferred_pragma): New interface.
	* lex.c (token_spellings): Adjust OP and TK definitions to
	match changes to cpplib.h.
	(_cpp_lex_token): Check for a directive-result token and
	return it if present.
	(cpp_token_val_index): Handle CPP_PRAGMA.
	* macro.c (cpp_builtin_macro_text): Correct comment.
	(builtin_macro): Handle directive-result tokens from _cpp_do__Pragma.

From-SVN: r87247
2004-09-09 19:16:56 +00:00
Bernardo Innocenti 72bb2c39ce internal.h (xnew, [...]): Remove.
* internal.h (xnew, xcnew, xnewvec, xcnewvec, xobnew): Remove.
	* directives.c: Use XNEW-family macros from libiberty.
	* lex.c: Likewise.
	* macro.c: Likewise.
	* cpplib.h (cpp_deps_style): Export enum with name.

From-SVN: r85121
2004-07-24 20:04:42 +02:00
Geoffrey Keating d8044160b7 Index: gcc/ChangeLog
2004-06-09  Geoffrey Keating  <geoffk@apple.com>

	* Makefile.in (CPPLIB_H): Put files in order of inclusion.
	(CPP_ID_DATA_H): New.
	(gtype-desc.o): Update dependencies.
	(GTFILES): Use CPP_ID_DATA_H.

Index: gcc/testsuite/ChangeLog
2004-06-09  Geoffrey Keating  <geoffk@apple.com>

	* gcc.dg/pch/macro-4.c: New.
	* gcc.dg/pch/macro-4.hs: New.

Index: libcpp/ChangeLog
2004-06-09  Geoffrey Keating  <geoffk@apple.com>

	* traditional.c (push_replacement_text): Set macro->traditional.
	(save_replacement_text): Likewise.
	* pch.c (cpp_write_pch_state): Don't write list of defined macros.
	(struct save_macro_item): Delete.
	(struct save_macro_data): Use a character array not the previous
	structured format.
	(save_macros): Save macro as text not as internal structures.
	(cpp_prepare_state): Update for changes to save_macro_data.
	(cpp_read_state): Don't read macros defined in PCH.  Restore
	-D macros as text.
	* macro.c (create_iso_definition): Honour alloc_subobject.
	Clear traditional flag.
	(_cpp_create_definition): Honour alloc_subobject.
	* lex.c (cpp_token_val_index): New.
	* internal.h: Include cpp-id-data.h.
	(uchar): Move definition to cpp-id-data.h.
	(U): Likewise.
	(cpp_macro): Likewise.
	* directives.c (struct answer): Move to cpp-id-data.h.
	(do_assert): Honour alloc_subobject.

Index: libcpp/include/ChangeLog
2004-06-09  Geoffrey Keating  <geoffk@apple.com>

	* symtab.h (struct ht): Add field 'alloc_subobject'.
	* cpplib.h (struct cpp_string): Add GTY marker.
	(enum cpp_token_fld_kind): New.
	(struct cpp_token): Add GTY markers.
	(cpp_token_val_index): Prototype.
	(CPP_HASHNODE_VALUE_IDX): New.
	(struct cpp_hashnode): Don't skip fields of 'value' when marking.
	* cpp-id-data.h: New file.

From-SVN: r82851
2004-06-09 20:10:13 +00:00
Zack Weinberg c6e8380069 Makefile.am: Add makedepend.
libcpp:
	* Makefile.am: Add makedepend.
	* Makefile.in, aclocal.m4: Regenerate.
	* charset.c: Insert a space to avoid a warning.
	* directives.c: Include mkdeps.h.
	(_cpp_handle_directive): Reenable macro expander if appropriate.
	(undefine_macros): Inline body of _cpp_free_definition for speed.
	Do not call undef callback or _cpp_warn_if_unused_macro.
	(cpp_get_deps): New interface.
	* files.c (search_cache): Add pfile argument.  Check for file
	that would be found by "" or <> search here...
	(_cpp_find_file): ...not here.  Correct recorded start_dir of
	files found by directory-of-current-file search that would be
	found by "" or <> search.
	* init.c (cpp_add_dependency_target): Delete.
	* internal.h (struct lexer_state): Add discarding_output flag.
	* lex.c (lex_identifier): Compute hash function while scanning.
	* macro.c (cpp_scan_nooutput): Disable macro expansion outside
	directives.
	* makedepend.c: New file.
	* mkdeps.c (struct deps): Add vpath vector.
	(apply_vpath, deps_add_vpath): New function.
	(deps_free): Free vpath vector.
	(deps_add_dep, deps_add_target): Use apply_vpath.
	* symtab.c (calc_hash): Use HT_HASHSTEP and HT_FINISH.
	(ht_lookup_with_hash): New function.
	* cpplib.h, mkdeps.h: Update prototypes.
	* symtab.h: Update prototypes.
	(HT_HASHSTEP, HT_FINISH): New macros.

gcc:
	* Makefile.in (MKDEPS_H): New shorthand.
	(c-opts.o): Update dependencies.
	* c-opts.c: Include mkdeps.h.
	(handle_deferred_opts): Use cpp_get_deps and deps_add_target,
	not cpp_add_dependency_target.

From-SVN: r82654
2004-06-05 20:58:06 +00:00
Paolo Bonzini 4f4e53dd85 Makefile.def (host_modules): add libcpp.
ChangeLog:

2004-05-23  Paolo Bonzini  <bonzini@gnu.org>

	* Makefile.def (host_modules): add libcpp.
	* Makefile.tpl: Add dependencies on and for libcpp.
	* Makefile.in: Regenerate.
	* configure.in: Add libcpp host module.
	* configure: Regenerate.

config/ChangeLog:

2004-05-23  Paolo Bonzini  <bonzini@gnu.org>

	* acx.m4 (ACX_HEADER_STDBOOL, ACX_HEADER_STRING):
	From gcc.

gcc/ChangeLog:

2004-05-23  Paolo Bonzini  <bonzini@gnu.org>

	Move libcpp to the toplevel.
	* Makefile.in: Remove references to libcpp files,
	use CPPLIBS instead of libcpp.a.  Define SYMTAB_H
	and change hashtable.h to that.
	* aclocal.m4 (gcc_AC_HEADER_STDBOOL,
	gcc_AC_HEADER_STRING, gcc_AC_C__BOOL): Remove.
	* configure.ac (gcc_AC_C__BOOL, HAVE_UCHAR): Remove tests.
	* configure: Regenerate.
	* config.in: Regenerate.
	* c-ppoutput.c: Include ../libcpp/internal.h instead of cpphash.h.
	* cppcharset.c: Removed.
	* cpperror.c: Removed.
	* cppexp.c: Removed.
	* cppfiles.c: Removed.
	* cpphash.c: Removed.
	* cpphash.h: Removed.
	* cppinit.c: Removed.
	* cpplex.c: Removed.
	* cpplib.c: Removed.
	* cpplib.h: Removed.
	* cppmacro.c: Removed.
	* cpppch.c: Removed.
	* cpptrad.c: Removed.
	* cppucnid.h: Removed.
	* cppucnid.pl: Removed.
	* cppucnid.tab: Removed.
	* hashtable.c: Removed.
	* hashtable.h: Removed.
	* line-map.c: Removed.
	* line-map.h: Removed.
	* mkdeps.c: Removed.
	* mkdeps.h: Removed.
	* stringpool.h: Include symtab.h instead of hashtable.h.
	* tree.h: Include symtab.h instead of hashtable.h.
	* system.h (O_NONBLOCK, O_NOCTTY): Do not define.

gcc/cp/ChangeLog:

2004-05-23  Paolo Bonzini  <bonzini@gnu.org>

	* Make-lang.in: No need to specify $(LIBCPP).

gcc/java/ChangeLog:

2004-05-23  Paolo Bonzini  <bonzini@gnu.org>

	* Make-lang.in: Link in $(LIBCPP) instead of mkdeps.o.

libcpp/ChangeLog:

2004-05-23  Paolo Bonzini  <bonzini@gnu.org>

	Moved libcpp from the gcc subdirectory to the toplevel.
	* Makefile.am: New file.
	* Makefile.in: Regenerate.
	* configure.ac: New file.
	* configure: Regenerate.
	* config.in: Regenerate.
	* charset.c: Moved from gcc/cppcharset.c.  Add note about
	brokenness of input charset detection.  Adjust for change
	in name of cppucnid.h.
	* errors.c: Moved from gcc/cpperror.c.  Do not include intl.h.
	* expr.c: Moved from gcc/cppexp.c.
	* files.c: Moved from gcc/cppfiles.c.  Do not include intl.h.
	Remove #define of O_BINARY, it is in system.h.
	* identifiers.c: Moved from gcc/cpphash.c.
	* internal.h: Moved from gcc/cpphash.h.  Change header
	guard name.  All other files adjusted to match name change.
	* init.c: Moved from gcc/cppinit.c.
	(init_library) [ENABLE_NLS]: Call bindtextdomain.
	* lex.c: Moved from gcc/cpplex.c.
	* directives.c: Moved from gcc/cpplib.c.
	* macro.c: Moved from gcc/cppmacro.c.
	* pch.c: Moved from gcc/cpppch.c.  Do not include intl.h.
	* traditional.c: Moved from gcc/cpptrad.c.
	* ucnid.h: Moved from gcc/cppucnid.h.  Change header
	guard name.
	* ucnid.pl: Moved from gcc/cppucnid.pl.
	* ucnid.tab: Moved from gcc/cppucnid.tab.  Change header
	guard name.
	* symtab.c: Moved from gcc/hashtable.c.
	* line-map.c: Moved from gcc.  Do not include intl.h.
	* mkdeps.c: Moved from gcc.
	* system.h: New file.

libcpp/include/ChangeLog:

2004-05-23  Paolo Bonzini  <bonzini@gnu.org>

	* cpplib.h: Moved from gcc.  Change header guard name.
	* line-map.h: Moved from gcc.  Change header guard name.
	* mkdeps.h: Moved from gcc.  Change header guard name.
	* symtab.h: Moved from gcc/hashtable.h.  Change header
	guard name.

libcpp/po/ChangeLog:

2004-05-23  Paolo Bonzini  <bonzini@gnu.org>

	* be.po: Extracted from gcc/po/be.po.
	* ca.po: Extracted from gcc/po/ca.po.
	* da.po: Extracted from gcc/po/da.po.
	* de.po: Extracted from gcc/po/de.po.
	* el.po: Extracted from gcc/po/el.po.
	* es.po: Extracted from gcc/po/es.po.
	* fr.po: Extracted from gcc/po/fr.po.
	* ja.po: Extracted from gcc/po/ja.po.
	* nl.po: Extracted from gcc/po/nl.po.
	* sv.po: Extracted from gcc/po/sv.po.
	* tr.po: Extracted from gcc/po/tr.po.

From-SVN: r82199
2004-05-24 10:50:45 +00:00