diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2008-07-11 18:16:26 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2008-07-11 18:16:26 +0000 |
commit | eea1139b26437bb71fd5ee838d8d0b5f2473a16a (patch) | |
tree | c00388a092ba64841d77b31eb539029bb96b0622 /gcc/c-common.h | |
parent | 94eeabbe1999a998aa8fb64a86e794c77755d0df (diff) | |
download | gcc-eea1139b26437bb71fd5ee838d8d0b5f2473a16a.zip gcc-eea1139b26437bb71fd5ee838d8d0b5f2473a16a.tar.gz gcc-eea1139b26437bb71fd5ee838d8d0b5f2473a16a.tar.bz2 |
c-common.h (enum rid): Add RID_CXX_COMPAT_WARN.
./: * c-common.h (enum rid): Add RID_CXX_COMPAT_WARN.
(struct c_common_resword): Define.
(D_CONLY, D_CXXONLY, D_C99, D_CXX0X, D_EXT, D_EXT89): Define.
(D_ASM, D_OBJC, D_CXX_OBJC, D_CXXWARN): Define.
(c_common_reswords, num_c_common_reswords): Declare.
* c-common.c (c_common_reswords): New global const array.
(num_c_common_reswords): New const int.
* c-parser.c (struct resword, reswords): Don't define.
(D_C89, D_EXT, D_EXT89, D_OBJC): Don't define.
(c_parse_init): Clarify mask code. Use c_common_reswords rather
than reswords. If warning about C++ keywords, give them a special
RID code.
(c_lex_one_token): Warn about C++ keywords. Call
objc_is_reserved_word rather than OBJC_IS_AT_KEYWORD.
(c_parser_external_declaration): Look for RID_xxx rather than
RID_AT_xxx, for ObjC++ keywords which are also C++ keywords.
(c_parser_statement_after_labels): Likewise.
(c_parser_objc_class_instance_variables): Likewise.
(c_parser_objc_class_declaration): Likewise.
(c_parser_objc_try_catch_statement): Likewise.
* c-decl.c (c_print_identifier): Ignore RID_CXX_COMPAT_WARN.
(declspecs_add_type): Likewise.
cp/:
* lex.c (struct resword, reswords): Don't define.
(D_EXT, D_ASM, D_OBJC, D_CXX0X): Don't define.
(init_reswords): Clarify mask code. Use c_common_reswords rather
than reswords.
objc/:
* objc-act.c (objc_is_reserved_word): Always check for RID_CLASS,
etc., not just when OBJCPLUS is defined.
testsuite/:
* gcc.dg/Wcxx-compat-2.c: New test.
From-SVN: r137724
Diffstat (limited to 'gcc/c-common.h')
-rw-r--r-- | gcc/c-common.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/gcc/c-common.h b/gcc/c-common.h index 7fd2242..7edb4a6 100644 --- a/gcc/c-common.h +++ b/gcc/c-common.h @@ -74,6 +74,10 @@ enum rid RID_DFLOAT32, RID_DFLOAT64, RID_DFLOAT128, RID_FRACT, RID_ACCUM, + /* This means to warn that this is a C++ keyword, and then treat it + as a normal identifier. */ + RID_CXX_COMPAT_WARN, + /* Too many ways of getting the name of a function as a string */ RID_FUNCTION_NAME, RID_PRETTY_FUNCTION_NAME, RID_C99_FUNCTION_NAME, @@ -197,6 +201,36 @@ struct c_common_identifier GTY(()) struct cpp_hashnode node; }; +/* An entry in the reserved keyword table. */ + +struct c_common_resword +{ + const char *const word; + ENUM_BITFIELD(rid) const rid : 16; + const unsigned int disable : 16; +}; + +/* Disable mask. Keywords are disabled if (reswords[i].disable & + mask) is _true_. Thus for keywords which are present in all + languages the disable field is zero. */ + +#define D_CONLY 0x001 /* C only (not in C++). */ +#define D_CXXONLY 0x002 /* C++ only (not in C). */ +#define D_C99 0x004 /* In C, C99 only. */ +#define D_CXX0X 0x008 /* In C++, C++0X only. */ +#define D_EXT 0x010 /* GCC extension. */ +#define D_EXT89 0x020 /* GCC extension incorporated in C99. */ +#define D_ASM 0x040 /* Disabled by -fno-asm. */ +#define D_OBJC 0x080 /* In Objective C and neither C nor C++. */ +#define D_CXX_OBJC 0x100 /* In Objective C, and C++, but not C. */ +#define D_CXXWARN 0x200 /* In C warn with -Wcxx-compat. */ + +/* The reserved keyword table. */ +extern const struct c_common_resword c_common_reswords[]; + +/* The number of items in the reserved keyword table. */ +extern const unsigned int num_c_common_reswords; + #define char16_type_node c_global_trees[CTI_CHAR16_TYPE] #define char32_type_node c_global_trees[CTI_CHAR32_TYPE] #define wchar_type_node c_global_trees[CTI_WCHAR_TYPE] |