aboutsummaryrefslogtreecommitdiff
path: root/libcpp/lex.c
AgeCommit message (Collapse)AuthorFilesLines
2013-07-21re PR preprocessor/57620 (Phantom terminator confuses raw string literal ↵Jakub Jelinek1-73/+118
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-10re PR preprocessor/57824 (Raw string literals not handled correctly in macro ↵Jakub Jelinek1-2/+2
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-10c-ppoutput.c (scan_translation_unit): Call account_for_newlines for all ↵Jakub Jelinek1-1/+1
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-10re PR preprocessor/57757 (CPP extra inserted whitespace needs to be reviewed ↵Jakub Jelinek1-0/+9
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-06-29lex.c (lex_raw_string(), [...]): Constrain suffixes treated as concatenated ↵Ed Smith-Rowland1-20/+39
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-04-24cpplib.h (enum c_lang): Add CLK_GNUCXX1Y and CLK_CXX1Y.Paolo Carlini1-2/+2
/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-02-28configure.ac: Don't define ENABLE_CHECKING whenever --enable-checking is seen...Jakub Jelinek1-0/+13
* 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-14re PR c++/55582 ([C++11] Unable to define string user-defined literal ↵Ed Smith-Rowland1-6/+10
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-01-14Update copyright years in libcpp.Richard Sandiford1-2/+1
From-SVN: r195162
2013-01-04PR c++/54526 (again)Paolo Carlini1-2/+13
/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
2012-10-15files.c (read_file_guts, [...]): Free memory before returning.Tobias Burnus1-0/+1
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-06-19lex.c (search_line_sse42): Use __builtin_ia32_loaddqu and ↵Uros Bizjak1-2/+5
__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-05-29PR bootstrap/53459 - unused local typedef when building on altivecDodji Seketeli1-2/+2
PR bootstrap/53459 * lex.c (search_line_fast): Avoid unused local typedefs to simulate a static assertion. From-SVN: r187947
2012-05-29Revert "PR bootstrap/53459 - unused local typedef when building on altivec"Dodji Seketeli1-0/+1
This reverts commit r187853 From-SVN: r187946
2012-05-24PR bootstrap/53459 - unused local typedef when building on altivecDodji Seketeli1-1/+0
libcpp/ PR bootstrap/53459 * lex.c (search_line_fast): Remove unused typedef check_count. From-SVN: r187853
2012-04-29Don't use C++ style comments in libcppDodji Seketeli1-2/+2
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-27Add new option, -Wliteral-suffix.Ollie Wild1-6/+38
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-03-22* lex.c (search_line_fast): Provide Neon-optimized version for ARM.Richard Earnshaw1-0/+63
From-SVN: r185702
2012-03-14Remove obsolete Solaris 8 supportRainer Orth1-2/+1
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
2011-12-07re PR bootstrap/50237 (bootstrap comparison failure for libcpp/lex.o)Jakub Jelinek1-1/+12
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-10-26Implement C++11 user-defined literals.Ed Smith-Rowland1-0/+25
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-22Fix cpp_peek_token behaviour (PR bootstrap/50778)Dodji Seketeli1-9/+7
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-20Fix thinko in _cpp_remaining_tokens_num_in_contextDodji Seketeli1-4/+2
libcpp/ * lex.c (_cpp_remaining_tokens_num_in_context): Fix computation of number of tokens. From-SVN: r180239
2011-10-17Generate virtual locations for tokensTom Tromey1-7/+34
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-08-22Add ability to force lexed tokens' source_locations.Gabriel Charette1-2/+23
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-18c1x-uni-string-1.c, [...]: New tests.Joseph Myers1-5/+7
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-15LINEMAP_POSITION_FOR_COLUMN had the exact same effect as ↵Gabriel Charette1-2/+2
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-06-16re PR c++/45399 ([C++0x] Warning for \0 in raw strings)Jason Merrill1-8/+0
PR c++/45399 * lex.c (lex_raw_string): Don't check for embedded NUL. From-SVN: r175121
2011-05-22* lex.c (init_vectorized_lexer): Fix comparison of masked value.Uros Bizjak1-1/+2
From-SVN: r174037
2011-05-22re PR bootstrap/49104 (bootstrap failure on AMD K6-2 with illegal ↵Uros Bizjak1-3/+3
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-04-24re PR preprocessor/48740 (Raw C++0x strings and trigraphs mix badly)Jakub Jelinek1-1/+3
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-03-18re PR bootstrap/45381 (Bootstrap failure for powerpc-apple-darwin9: error: ↵Richard Henderson1-1/+1
AltiVec argument passed to unprototyped function) PR bootstrap/45381 * lex.c [ALTIVEC] (search_line_fast): Require gcc version 4.5. From-SVN: r171165
2010-11-16re PR preprocessor/17349 (// comments cause weird behaviour with options -E -C)Kai Tietz1-6/+12
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-08-24re PR bootstrap/45376 (no such instruction: `pcmpestri $0,(%rdi),%xmm0')Richard Henderson1-0/+6
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-24lex.c: Disable init_vectorized_lexer etc.Rainer Orth1-1/+11
* lex.c [__sun__ && __svr4__]: Disable init_vectorized_lexer etc. on Solaris 2/x86. From-SVN: r163522
2010-08-21Vectorize fast path of _cpp_clean_line.Richard Henderson1-56/+589
* 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-04-07diagnostic.h (diagnostic_override_option_index): New macro to set a ↵Simon Baldwin1-20/+23
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-06re PR preprocessor/43642 (FAIL: c-c++-common/raw-string-1.c)Jakub Jelinek1-1/+1
PR preprocessor/43642 * lex.c (lex_raw_string): Change type of TYPE variable to unsigned char. From-SVN: r157979
2010-03-29More N3077 raw string changesJason Merrill1-30/+131
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-29Some raw string changes from N3077Jason Merrill1-5/+5
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
2009-11-11ChangeLog for libcppKai Tietz1-0/+57
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-10-19charset.c (cpp_init_iconv): Initialize utf8_cset_desc.Jakub Jelinek1-10/+213
* 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-06-12cpplib.h (struct cpp_options): Add warn_cxx_operator_names field.Ian Lance Taylor1-0/+6
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-05-10c-lex.c (c_lex_with_flags): Expect cpp_hashnode in tok->val.node.node.Joseph Myers1-23/+24
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-04-22re PR c++/14875 (When using 'or' keyword, the error message speaks of a '||' ↵Manuel López-Ibáñez1-7/+18
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-19re PR preprocessor/20078 (Gcc doesn't complain about non-benign macro ↵Joseph Myers1-3/+10
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-09Licensing changes to GPLv3 resp. GPLv3 with GCC Runtime Exception.Jakub Jelinek1-4/+5
From-SVN: r145841
2009-02-21lex.c (lex_string): Return a CPP_LESS token for missing '>' in a header name.Joseph Myers1-2/+13
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
2008-11-29lex.c (cpp_token_len): Use 6 as default length.Joseph Myers1-1/+1
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-10-05cpplib.h (cpp_comments, [...]): New structs.Matthew Gingell1-0/+49
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