From aa50850225d70521ace3948a8e5858425a918f6a Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Sun, 19 Apr 2009 18:10:56 +0100 Subject: 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 --- libcpp/include/cpp-id-data.h | 5 +++++ libcpp/include/cpplib.h | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'libcpp/include') diff --git a/libcpp/include/cpp-id-data.h b/libcpp/include/cpp-id-data.h index afe4eda..029d424 100644 --- a/libcpp/include/cpp-id-data.h +++ b/libcpp/include/cpp-id-data.h @@ -75,4 +75,9 @@ struct cpp_macro GTY(()) /* Indicate which field of 'exp' is in use. */ unsigned int traditional : 1; + + /* Indicate whether the tokens include extra CPP_PASTE tokens at the + end to track invalid redefinitions with consecutive CPP_PASTE + tokens. */ + unsigned int extra_tokens : 1; }; diff --git a/libcpp/include/cpplib.h b/libcpp/include/cpplib.h index 434308b..3aeb035 100644 --- a/libcpp/include/cpplib.h +++ b/libcpp/include/cpplib.h @@ -178,6 +178,10 @@ struct cpp_string GTY(()) #define BOL (1 << 6) /* Token at beginning of line. */ #define PURE_ZERO (1 << 7) /* Single 0 digit, used by the C++ frontend, set in c-lex.c. */ +#define SP_DIGRAPH (1 << 8) /* # or ## token was a digraph. */ +#define SP_PREV_WHITE (1 << 9) /* If whitespace before a ## + operator, or before this token + after a # operator. */ /* Specify which field, if any, of the cpp_token union is used. */ @@ -196,7 +200,7 @@ struct cpp_token GTY(()) { source_location src_loc; /* Location of first char of token. */ ENUM_BITFIELD(cpp_ttype) type : CHAR_BIT; /* token type */ - unsigned char flags; /* flags - see above */ + unsigned short flags; /* flags - see above */ union cpp_token_u { -- cgit v1.1