summaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c173
1 files changed, 173 insertions, 0 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 9356b8e925e..f54b1cb0942 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -585,6 +585,179 @@ static bool nonnull_check_p (tree, unsigned HOST_WIDE_INT);
static bool get_nonnull_operand (tree, unsigned HOST_WIDE_INT *);
static int resort_field_decl_cmp (const void *, const void *);
+/* Reserved words. The third field is a mask: keywords are disabled
+ if they match the mask.
+
+ Masks for languages:
+ C --std=c89: D_C99 | D_CXXONLY | D_OBJC | D_CXX_OBJC
+ C --std=c99: D_CXXONLY | D_OBJC
+ ObjC is like C except that D_OBJC and D_CXX_OBJC are not set
+ C++ --std=c98: D_CONLY | D_CXXOX | D_OBJC
+ C++ --std=c0x: D_CONLY | D_OBJC
+ ObjC++ is like C++ except that D_OBJC is not set
+
+ If -fno-asm is used, D_ASM is added to the mask. If
+ -fno-gnu-keywords is used, D_EXT is added. If -fno-asm and C in
+ C89 mode, D_EXT89 is added for both -fno-asm and -fno-gnu-keywords.
+ In C with -Wcxx-compat, we warn if D_CXXWARN is set. */
+
+const struct c_common_resword c_common_reswords[] =
+{
+ { "_Bool", RID_BOOL, D_CONLY },
+ { "_Complex", RID_COMPLEX, 0 },
+ { "_Decimal32", RID_DFLOAT32, D_CONLY | D_EXT },
+ { "_Decimal64", RID_DFLOAT64, D_CONLY | D_EXT },
+ { "_Decimal128", RID_DFLOAT128, D_CONLY | D_EXT },
+ { "_Fract", RID_FRACT, D_CONLY | D_EXT },
+ { "_Accum", RID_ACCUM, D_CONLY | D_EXT },
+ { "_Sat", RID_SAT, D_CONLY | D_EXT },
+ { "__FUNCTION__", RID_FUNCTION_NAME, 0 },
+ { "__PRETTY_FUNCTION__", RID_PRETTY_FUNCTION_NAME, 0 },
+ { "__alignof", RID_ALIGNOF, 0 },
+ { "__alignof__", RID_ALIGNOF, 0 },
+ { "__asm", RID_ASM, 0 },
+ { "__asm__", RID_ASM, 0 },
+ { "__attribute", RID_ATTRIBUTE, 0 },
+ { "__attribute__", RID_ATTRIBUTE, 0 },
+ { "__builtin_choose_expr", RID_CHOOSE_EXPR, D_CONLY },
+ { "__builtin_offsetof", RID_OFFSETOF, 0 },
+ { "__builtin_types_compatible_p", RID_TYPES_COMPATIBLE_P, D_CONLY },
+ { "__builtin_va_arg", RID_VA_ARG, 0 },
+ { "__complex", RID_COMPLEX, 0 },
+ { "__complex__", RID_COMPLEX, 0 },
+ { "__const", RID_CONST, 0 },
+ { "__const__", RID_CONST, 0 },
+ { "__decltype", RID_DECLTYPE, D_CXXONLY },
+ { "__extension__", RID_EXTENSION, 0 },
+ { "__func__", RID_C99_FUNCTION_NAME, 0 },
+ { "__has_nothrow_assign", RID_HAS_NOTHROW_ASSIGN, D_CXXONLY },
+ { "__has_nothrow_constructor", RID_HAS_NOTHROW_CONSTRUCTOR, D_CXXONLY },
+ { "__has_nothrow_copy", RID_HAS_NOTHROW_COPY, D_CXXONLY },
+ { "__has_trivial_assign", RID_HAS_TRIVIAL_ASSIGN, D_CXXONLY },
+ { "__has_trivial_constructor", RID_HAS_TRIVIAL_CONSTRUCTOR, D_CXXONLY },
+ { "__has_trivial_copy", RID_HAS_TRIVIAL_COPY, D_CXXONLY },
+ { "__has_trivial_destructor", RID_HAS_TRIVIAL_DESTRUCTOR, D_CXXONLY },
+ { "__has_virtual_destructor", RID_HAS_VIRTUAL_DESTRUCTOR, D_CXXONLY },
+ { "__is_abstract", RID_IS_ABSTRACT, D_CXXONLY },
+ { "__is_base_of", RID_IS_BASE_OF, D_CXXONLY },
+ { "__is_class", RID_IS_CLASS, D_CXXONLY },
+ { "__is_convertible_to", RID_IS_CONVERTIBLE_TO, D_CXXONLY },
+ { "__is_empty", RID_IS_EMPTY, D_CXXONLY },
+ { "__is_enum", RID_IS_ENUM, D_CXXONLY },
+ { "__is_pod", RID_IS_POD, D_CXXONLY },
+ { "__is_polymorphic", RID_IS_POLYMORPHIC, D_CXXONLY },
+ { "__is_union", RID_IS_UNION, D_CXXONLY },
+ { "__imag", RID_IMAGPART, 0 },
+ { "__imag__", RID_IMAGPART, 0 },
+ { "__inline", RID_INLINE, 0 },
+ { "__inline__", RID_INLINE, 0 },
+ { "__label__", RID_LABEL, 0 },
+ { "__null", RID_NULL, 0 },
+ { "__real", RID_REALPART, 0 },
+ { "__real__", RID_REALPART, 0 },
+ { "__restrict", RID_RESTRICT, 0 },
+ { "__restrict__", RID_RESTRICT, 0 },
+ { "__signed", RID_SIGNED, 0 },
+ { "__signed__", RID_SIGNED, 0 },
+ { "__thread", RID_THREAD, 0 },
+ { "__typeof", RID_TYPEOF, 0 },
+ { "__typeof__", RID_TYPEOF, 0 },
+ { "__volatile", RID_VOLATILE, 0 },
+ { "__volatile__", RID_VOLATILE, 0 },
+ { "asm", RID_ASM, D_ASM },
+ { "auto", RID_AUTO, 0 },
+ { "bool", RID_BOOL, D_CXXONLY },
+ { "break", RID_BREAK, 0 },
+ { "case", RID_CASE, 0 },
+ { "catch", RID_CATCH, D_CXX_OBJC },
+ { "char", RID_CHAR, 0 },
+ { "char16_t", RID_CHAR16, D_CXXONLY | D_CXX0X },
+ { "char32_t", RID_CHAR32, D_CXXONLY | D_CXX0X },
+ { "class", RID_CLASS, D_CXX_OBJC },
+ { "const", RID_CONST, 0 },
+ { "const_cast", RID_CONSTCAST, D_CXXONLY | D_CXXWARN },
+ { "continue", RID_CONTINUE, 0 },
+ { "decltype", RID_DECLTYPE, D_CXXONLY | D_CXX0X },
+ { "default", RID_DEFAULT, 0 },
+ { "delete", RID_DELETE, D_CXXONLY },
+ { "do", RID_DO, 0 },
+ { "double", RID_DOUBLE, 0 },
+ { "dynamic_cast", RID_DYNCAST, D_CXXONLY | D_CXXWARN },
+ { "else", RID_ELSE, 0 },
+ { "enum", RID_ENUM, 0 },
+ { "explicit", RID_EXPLICIT, D_CXXONLY },
+ { "export", RID_EXPORT, D_CXXONLY },
+ { "extern", RID_EXTERN, 0 },
+ { "false", RID_FALSE, D_CXXONLY },
+ { "float", RID_FLOAT, 0 },
+ { "for", RID_FOR, 0 },
+ { "friend", RID_FRIEND, D_CXXONLY },
+ { "goto", RID_GOTO, 0 },
+ { "if", RID_IF, 0 },
+ { "inline", RID_INLINE, D_EXT89 },
+ { "int", RID_INT, 0 },
+ { "long", RID_LONG, 0 },
+ { "mutable", RID_MUTABLE, D_CXXONLY | D_CXXWARN },
+ { "namespace", RID_NAMESPACE, D_CXXONLY },
+ { "new", RID_NEW, D_CXXONLY },
+ { "operator", RID_OPERATOR, D_CXXONLY },
+ { "private", RID_PRIVATE, D_CXX_OBJC },
+ { "protected", RID_PROTECTED, D_CXX_OBJC },
+ { "public", RID_PUBLIC, D_CXX_OBJC },
+ { "register", RID_REGISTER, 0 },
+ { "reinterpret_cast", RID_REINTCAST, D_CXXONLY | D_CXXWARN },
+ { "restrict", RID_RESTRICT, D_CONLY | D_C99 },
+ { "return", RID_RETURN, 0 },
+ { "short", RID_SHORT, 0 },
+ { "signed", RID_SIGNED, 0 },
+ { "sizeof", RID_SIZEOF, 0 },
+ { "static", RID_STATIC, 0 },
+ { "static_assert", RID_STATIC_ASSERT, D_CXXONLY | D_CXX0X | D_CXXWARN },
+ { "static_cast", RID_STATCAST, D_CXXONLY | D_CXXWARN },
+ { "struct", RID_STRUCT, 0 },
+ { "switch", RID_SWITCH, 0 },
+ { "template", RID_TEMPLATE, D_CXXONLY },
+ { "this", RID_THIS, D_CXXONLY },
+ { "throw", RID_THROW, D_CXX_OBJC },
+ { "true", RID_TRUE, D_CXXONLY },
+ { "try", RID_TRY, D_CXX_OBJC },
+ { "typedef", RID_TYPEDEF, 0 },
+ { "typename", RID_TYPENAME, D_CXXONLY },
+ { "typeid", RID_TYPEID, D_CXXONLY },
+ { "typeof", RID_TYPEOF, D_ASM | D_EXT },
+ { "union", RID_UNION, 0 },
+ { "unsigned", RID_UNSIGNED, 0 },
+ { "using", RID_USING, D_CXXONLY },
+ { "virtual", RID_VIRTUAL, D_CXXONLY },
+ { "void", RID_VOID, 0 },
+ { "volatile", RID_VOLATILE, 0 },
+ { "wchar_t", RID_WCHAR, D_CXXONLY },
+ { "while", RID_WHILE, 0 },
+ /* These Objective-C keywords are recognized only immediately after
+ an '@'. */
+ { "compatibility_alias", RID_AT_ALIAS, D_OBJC },
+ { "defs", RID_AT_DEFS, D_OBJC },
+ { "encode", RID_AT_ENCODE, D_OBJC },
+ { "end", RID_AT_END, D_OBJC },
+ { "implementation", RID_AT_IMPLEMENTATION, D_OBJC },
+ { "interface", RID_AT_INTERFACE, D_OBJC },
+ { "protocol", RID_AT_PROTOCOL, D_OBJC },
+ { "selector", RID_AT_SELECTOR, D_OBJC },
+ { "finally", RID_AT_FINALLY, D_OBJC },
+ { "synchronized", RID_AT_SYNCHRONIZED, D_OBJC },
+ /* These are recognized only in protocol-qualifier context
+ (see above) */
+ { "bycopy", RID_BYCOPY, D_OBJC },
+ { "byref", RID_BYREF, D_OBJC },
+ { "in", RID_IN, D_OBJC },
+ { "inout", RID_INOUT, D_OBJC },
+ { "oneway", RID_ONEWAY, D_OBJC },
+ { "out", RID_OUT, D_OBJC },
+};
+
+const unsigned int num_c_common_reswords =
+ sizeof c_common_reswords / sizeof (struct c_common_resword);
+
/* Table of machine-independent attributes common to all C-like languages. */
const struct attribute_spec c_common_attribute_table[] =
{