/* Definitions for c-common.c.
Copyright (C) 1987, 1993, 1994, 1995, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011
Free Software Foundation, Inc.
This file is part of GCC.
/* In order for the format checking to accept the C frontend
diagnostic framework extensions, you must include this file before
- toplev.h, not after. The C front end formats are a subset of those
+ diagnostic-core.h, not after. The C front end formats are a subset of those
for C++, so they are the appropriate set to use in common code;
cp-tree.h overrides this for C++. */
+#if defined(GCC_DIAGNOSTIC_CORE_H)
+#error \
+In order for the format checking to accept the C front end diagnostic \
+framework extensions, you must include this file before diagnostic-core.h \
+never after.
+#endif
#ifndef GCC_DIAG_STYLE
#define GCC_DIAG_STYLE __gcc_cdiag__
#endif
/* Reserved identifiers. This is the union of all the keywords for C,
C++, and Objective-C. All the type modifiers have to be in one
block at the beginning, because they are used as mask bits. There
- are 27 type modifiers; if we add many more we will have to redesign
+ are 28 type modifiers; if we add many more we will have to redesign
the mask mechanism. */
enum rid
RID_UNSIGNED, RID_LONG, RID_CONST, RID_EXTERN,
RID_REGISTER, RID_TYPEDEF, RID_SHORT, RID_INLINE,
RID_VOLATILE, RID_SIGNED, RID_AUTO, RID_RESTRICT,
+ RID_NORETURN,
/* C extensions */
RID_COMPLEX, RID_THREAD, RID_SAT,
/* C++ */
RID_FRIEND, RID_VIRTUAL, RID_EXPLICIT, RID_EXPORT, RID_MUTABLE,
- /* ObjC */
+ /* ObjC ("PQ" reserved words - they do not appear after a '@' and
+ are keywords only in specific contexts) */
RID_IN, RID_OUT, RID_INOUT, RID_BYCOPY, RID_BYREF, RID_ONEWAY,
+ /* ObjC ("PATTR" reserved words - they do not appear after a '@'
+ and are keywords only as property attributes) */
+ RID_GETTER, RID_SETTER,
+ RID_READONLY, RID_READWRITE,
+ RID_ASSIGN, RID_RETAIN, RID_COPY,
+ RID_NONATOMIC,
+
/* C (reserved and imaginary types not implemented, so any use is a
syntax error) */
RID_IMAGINARY,
/* C extensions */
RID_ASM, RID_TYPEOF, RID_ALIGNOF, RID_ATTRIBUTE, RID_VA_ARG,
RID_EXTENSION, RID_IMAGPART, RID_REALPART, RID_LABEL, RID_CHOOSE_EXPR,
- RID_TYPES_COMPATIBLE_P,
+ RID_TYPES_COMPATIBLE_P, RID_BUILTIN_COMPLEX,
RID_DFLOAT32, RID_DFLOAT64, RID_DFLOAT128,
RID_FRACT, RID_ACCUM,
/* Too many ways of getting the name of a function as a string */
RID_FUNCTION_NAME, RID_PRETTY_FUNCTION_NAME, RID_C99_FUNCTION_NAME,
- /* C++ */
+ /* C++ (some of these are keywords in Objective-C as well, but only
+ if they appear after a '@') */
RID_BOOL, RID_WCHAR, RID_CLASS,
RID_PUBLIC, RID_PRIVATE, RID_PROTECTED,
RID_TEMPLATE, RID_NULL, RID_CATCH,
RID_IS_ABSTRACT, RID_IS_BASE_OF,
RID_IS_CONVERTIBLE_TO, RID_IS_CLASS,
RID_IS_EMPTY, RID_IS_ENUM,
- RID_IS_POD, RID_IS_POLYMORPHIC,
- RID_IS_STD_LAYOUT, RID_IS_TRIVIAL,
- RID_IS_UNION,
+ RID_IS_LITERAL_TYPE, RID_IS_POD,
+ RID_IS_POLYMORPHIC, RID_IS_STD_LAYOUT,
+ RID_IS_TRIVIAL, RID_IS_UNION,
+ RID_UNDERLYING_TYPE,
/* C++0x */
RID_CONSTEXPR, RID_DECLTYPE, RID_NOEXCEPT, RID_NULLPTR, RID_STATIC_ASSERT,
- /* Objective-C */
+ /* Objective-C ("AT" reserved words - they are only keywords when
+ they follow '@') */
RID_AT_ENCODE, RID_AT_END,
RID_AT_CLASS, RID_AT_ALIAS, RID_AT_DEFS,
- RID_AT_PRIVATE, RID_AT_PROTECTED, RID_AT_PUBLIC,
+ RID_AT_PRIVATE, RID_AT_PROTECTED, RID_AT_PUBLIC, RID_AT_PACKAGE,
RID_AT_PROTOCOL, RID_AT_SELECTOR,
RID_AT_THROW, RID_AT_TRY, RID_AT_CATCH,
- RID_AT_FINALLY, RID_AT_SYNCHRONIZED,
+ RID_AT_FINALLY, RID_AT_SYNCHRONIZED,
+ RID_AT_OPTIONAL, RID_AT_REQUIRED, RID_AT_PROPERTY,
+ RID_AT_SYNTHESIZE, RID_AT_DYNAMIC,
RID_AT_INTERFACE,
RID_AT_IMPLEMENTATION,
RID_FIRST_AT = RID_AT_ENCODE,
RID_LAST_AT = RID_AT_IMPLEMENTATION,
RID_FIRST_PQ = RID_IN,
- RID_LAST_PQ = RID_ONEWAY
+ RID_LAST_PQ = RID_ONEWAY,
+ RID_FIRST_PATTR = RID_GETTER,
+ RID_LAST_PATTR = RID_NONATOMIC
};
#define OBJC_IS_AT_KEYWORD(rid) \
((unsigned int) (rid) >= (unsigned int) RID_FIRST_PQ && \
(unsigned int) (rid) <= (unsigned int) RID_LAST_PQ)
+#define OBJC_IS_PATTR_KEYWORD(rid) \
+ ((unsigned int) (rid) >= (unsigned int) RID_FIRST_PATTR && \
+ (unsigned int) (rid) <= (unsigned int) RID_LAST_PATTR)
+
+/* OBJC_IS_CXX_KEYWORD recognizes the 'CXX_OBJC' keywords (such as
+ 'class') which are shared in a subtle way between Objective-C and
+ C++. When the lexer is lexing in Objective-C/Objective-C++, if it
+ finds '@' followed by one of these identifiers (eg, '@class'), it
+ recognizes the whole as an Objective-C keyword. If the identifier
+ is found elsewhere, it follows the rules of the C/C++ language.
+ */
+#define OBJC_IS_CXX_KEYWORD(rid) \
+ (rid == RID_CLASS \
+ || rid == RID_PUBLIC || rid == RID_PROTECTED || rid == RID_PRIVATE \
+ || rid == RID_TRY || rid == RID_THROW || rid == RID_CATCH)
+
/* The elements of `ridpointers' are identifier nodes for the reserved
type names and storage classes. It is indexed by a RID_... value. */
extern GTY ((length ("(int) RID_MAX"))) tree *ridpointers;
const unsigned int disable : 16;
};
+/* Extra cpp_ttype values for C++. */
+
+/* A token type for keywords, as opposed to ordinary identifiers. */
+#define CPP_KEYWORD ((enum cpp_ttype) (N_TTYPES + 1))
+
+/* A token type for template-ids. If a template-id is processed while
+ parsing tentatively, it is replaced with a CPP_TEMPLATE_ID token;
+ the value of the CPP_TEMPLATE_ID is whatever was returned by
+ cp_parser_template_id. */
+#define CPP_TEMPLATE_ID ((enum cpp_ttype) (CPP_KEYWORD + 1))
+
+/* A token type for nested-name-specifiers. If a
+ nested-name-specifier is processed while parsing tentatively, it is
+ replaced with a CPP_NESTED_NAME_SPECIFIER token; the value of the
+ CPP_NESTED_NAME_SPECIFIER is whatever was returned by
+ cp_parser_nested_name_specifier_opt. */
+#define CPP_NESTED_NAME_SPECIFIER ((enum cpp_ttype) (CPP_TEMPLATE_ID + 1))
+
+/* A token type for pre-parsed C++0x decltype. */
+#define CPP_DECLTYPE ((enum cpp_ttype) (CPP_NESTED_NAME_SPECIFIER + 1))
+
+/* The number of token types, including C++-specific ones. */
+#define N_CP_TTYPES ((int) (CPP_DECLTYPE + 1))
+
/* 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. */
/* In a RECORD_TYPE, a sorted array of the fields of the type, not a
tree for size reasons. */
-struct GTY(()) sorted_fields_type {
+struct GTY((variable_size)) sorted_fields_type {
int len;
tree GTY((length ("%h.len"))) elts[1];
};
/* Information about a statement tree. */
struct GTY(()) stmt_tree_s {
- /* The current statement list being collected. */
- tree x_cur_stmt_list;
+ /* A stack of statement lists being collected. */
+ VEC(tree,gc) *x_cur_stmt_list;
/* In C++, Nonzero if we should treat statements as full
expressions. In particular, this variable is no-zero if at the
/* While we are parsing the function, this contains information
about the statement-tree that we are building. */
struct stmt_tree_s x_stmt_tree;
+
+ /* Vector of locally defined typedefs, for
+ -Wunused-local-typedefs. */
+ VEC(tree,gc) *local_typedefs;
};
+#define stmt_list_stack (current_stmt_tree ()->x_cur_stmt_list)
+
/* When building a statement-tree, this is the current statement list
- being collected. It's TREE_CHAIN is a back-pointer to the previous
- statement list. */
+ being collected. We define it in this convoluted way, rather than
+ using VEC_last, because it must be an lvalue. */
-#define cur_stmt_list (current_stmt_tree ()->x_cur_stmt_list)
+#define cur_stmt_list \
+ (*(VEC_address (tree, stmt_list_stack) \
+ + VEC_length (tree, stmt_list_stack) - 1))
+
+#define building_stmt_list_p() (!VEC_empty (tree, stmt_list_stack))
/* Language-specific hooks. */
extern int print_struct_values;
-/* ???. Undocumented. */
+/* Tells the compiler what is the constant string class for ObjC. */
extern const char *constant_string_class_name;
/* Maximum template instantiation depth. This limit is rather
arbitrary, but it exists to limit the time it takes to notice
- infinite template instantiations. */
+ excessively recursive template instantiations. */
extern int max_tinst_depth;
#define C_TYPE_OBJECT_OR_INCOMPLETE_P(type) \
(!C_TYPE_FUNCTION_P (type))
+struct visibility_flags
+{
+ unsigned inpragma : 1; /* True when in #pragma GCC visibility. */
+ unsigned inlines_hidden : 1; /* True when -finlineshidden in effect. */
+};
+
+/* Global visibility options. */
+extern struct visibility_flags visibility_options;
+
/* Attribute table common to the C front ends. */
extern const struct attribute_spec c_common_attribute_table[];
extern const struct attribute_spec c_common_format_attribute_table[];
extern void c_register_addr_space (const char *str, addr_space_t as);
/* In c-common.c. */
+extern bool in_late_binary_op;
extern const char *c_addr_space_name (addr_space_t as);
extern tree identifier_global_value (tree);
+extern tree c_linkage_bindings (tree);
extern void record_builtin_type (enum rid, const char *, tree);
extern tree build_void_list_node (void);
extern void start_fname_decls (void);
extern const char *fname_as_string (int);
extern tree fname_decl (location_t, unsigned, tree);
-extern void check_function_arguments (tree, int, tree *, tree);
+extern void check_function_arguments (const_tree, int, tree *);
extern void check_function_arguments_recurse (void (*)
(void *, tree,
unsigned HOST_WIDE_INT),
extern tree handle_format_attribute (tree *, tree, tree, int, bool *);
extern tree handle_format_arg_attribute (tree *, tree, tree, int, bool *);
extern bool attribute_takes_identifier_p (const_tree);
-extern int c_common_handle_option (size_t code, const char *arg, int value, int kind);
-extern bool c_common_missing_argument (const char *opt, size_t code);
+extern bool c_common_handle_option (size_t, const char *, int, int, location_t,
+ const struct cl_option_handlers *);
+extern bool default_handle_c_option (size_t, const char *, int);
extern tree c_common_type_for_mode (enum machine_mode, int);
extern tree c_common_type_for_size (unsigned int, int);
extern tree c_common_fixed_point_type_for_size (unsigned int, unsigned int,
extern tree c_common_unsigned_type (tree);
extern tree c_common_signed_type (tree);
extern tree c_common_signed_or_unsigned_type (int, tree);
+extern void c_common_init_ts (void);
extern tree c_build_bitfield_integer_type (unsigned HOST_WIDE_INT, int);
+extern bool unsafe_conversion_p (tree, tree, bool);
extern bool decl_with_nonnull_addr_p (const_tree);
extern tree c_fully_fold (tree, bool, bool *);
extern tree decl_constant_value_for_optimization (tree);
extern void clear_float_const_decimal64 (void);
extern bool float_const_decimal64_p (void);
+extern bool keyword_begins_type_specifier (enum rid);
+extern bool keyword_is_storage_class_specifier (enum rid);
+extern bool keyword_is_type_qualifier (enum rid);
+extern bool keyword_is_decl_specifier (enum rid);
+
#define c_sizeof(LOC, T) c_sizeof_or_alignof_type (LOC, T, true, 1)
#define c_alignof(LOC, T) c_sizeof_or_alignof_type (LOC, T, false, 1)
extern tree build_va_arg (location_t, tree, tree);
-extern unsigned int c_common_init_options (unsigned int, const char **);
+extern const unsigned int c_family_lang_mask;
+extern unsigned int c_common_option_lang_mask (void);
+extern void c_common_initialize_diagnostics (diagnostic_context *);
+extern bool c_common_complain_wrong_lang_p (const struct cl_option *);
+extern void c_common_init_options_struct (struct gcc_options *);
+extern void c_common_init_options (unsigned int, struct cl_decoded_option *);
extern bool c_common_post_options (const char **);
extern bool c_common_init (void);
extern void c_common_finish (void);
-extern void c_common_parse_file (int);
+extern void c_common_parse_file (void);
extern alias_set_type c_common_get_alias_set (tree);
extern void c_register_builtin_type (tree, const char*);
extern bool c_promoting_integer_type_p (const_tree);
/* This is the basic parsing function. */
extern void c_parse_file (void);
-/* This is misnamed, it actually performs end-of-compilation processing. */
-extern void finish_file (void);
+extern void warn_for_omitted_condop (location_t, tree);
/* These macros provide convenient access to the various _STMT nodes. */
extern tree do_case (location_t, tree, tree);
extern tree build_stmt (location_t, enum tree_code, ...);
-extern tree build_case_label (location_t, tree, tree, tree);
+extern tree build_real_imag_expr (location_t, enum tree_code, tree);
/* These functions must be defined by each front-end which implements
a variant of the C language. They are used in c-common.c. */
const char *, va_list *)
ATTRIBUTE_GCC_DIAG(6,0);
+extern bool parse_optimize_options (tree, bool);
+
/* Positive if an implicit `extern "C"' scope has just been entered;
negative if such a scope has just been exited. */
extern GTY(()) int pending_lang_change;
lv_asm
};
-extern void lvalue_error (enum lvalue_use);
+extern void readonly_error (tree, enum lvalue_use);
+extern void lvalue_error (location_t, enum lvalue_use);
+extern void invalid_indirection_error (location_t, tree, ref_operator);
extern int complete_array_type (tree *, tree, bool);
extern tree builtin_type_for_size (int, bool);
+extern void c_common_mark_addressable_vec (tree);
+
extern void warn_array_subscript_with_type_char (tree);
extern void warn_about_parentheses (enum tree_code,
enum tree_code, tree,
tree op0, tree op1,
tree result_type,
enum tree_code resultcode);
-extern void set_underlying_type (tree x);
+extern void do_warn_double_promotion (tree, tree, tree, const char *,
+ location_t);
+extern void set_underlying_type (tree);
+extern void record_locally_defined_typedef (tree);
+extern void maybe_record_typedef_use (tree);
+extern void maybe_warn_unused_local_typedefs (void);
extern VEC(tree,gc) *make_tree_vector (void);
extern void release_tree_vector (VEC(tree,gc) *);
extern VEC(tree,gc) *make_tree_vector_single (tree);
+extern VEC(tree,gc) *make_tree_vector_from_list (tree);
extern VEC(tree,gc) *make_tree_vector_copy (const VEC(tree,gc) *);
/* In c-gimplify.c */
extern void fe_file_change (const struct line_map *);
extern void c_parse_error (const char *, enum cpp_ttype, tree, unsigned char);
-/* Objective-C / Objective-C++ entry points. */
-
-/* The following ObjC/ObjC++ functions are called by the C and/or C++
- front-ends; they all must have corresponding stubs in stub-objc.c. */
-extern tree objc_is_class_name (tree);
-extern tree objc_is_object_ptr (tree);
-extern void objc_check_decl (tree);
-extern int objc_is_reserved_word (tree);
-extern bool objc_compare_types (tree, tree, int, tree);
-extern void objc_volatilize_decl (tree);
-extern bool objc_type_quals_match (tree, tree);
-extern tree objc_rewrite_function_call (tree, tree);
-extern tree objc_message_selector (void);
-extern tree objc_lookup_ivar (tree, tree);
-extern void objc_clear_super_receiver (void);
-extern int objc_is_public (tree, tree);
-extern tree objc_is_id (tree);
-extern void objc_declare_alias (tree, tree);
-extern void objc_declare_class (tree);
-extern void objc_declare_protocols (tree);
-extern tree objc_build_message_expr (tree);
-extern tree objc_finish_message_expr (tree, tree, tree);
-extern tree objc_build_selector_expr (location_t, tree);
-extern tree objc_build_protocol_expr (tree);
-extern tree objc_build_encode_expr (tree);
-extern tree objc_build_string_object (tree);
-extern tree objc_get_protocol_qualified_type (tree, tree);
-extern tree objc_get_class_reference (tree);
-extern tree objc_get_class_ivars (tree);
-extern void objc_start_class_interface (tree, tree, tree);
-extern void objc_start_category_interface (tree, tree, tree);
-extern void objc_start_protocol (tree, tree);
-extern void objc_continue_interface (void);
-extern void objc_finish_interface (void);
-extern void objc_start_class_implementation (tree, tree);
-extern void objc_start_category_implementation (tree, tree);
-extern void objc_continue_implementation (void);
-extern void objc_finish_implementation (void);
-extern void objc_set_visibility (int);
-extern void objc_set_method_type (enum tree_code);
-extern tree objc_build_method_signature (tree, tree, tree, bool);
-extern void objc_add_method_declaration (tree);
-extern void objc_start_method_definition (tree);
-extern void objc_finish_method_definition (tree);
-extern void objc_add_instance_variable (tree);
-extern tree objc_build_keyword_decl (tree, tree, tree);
-extern tree objc_build_throw_stmt (location_t, tree);
-extern void objc_begin_try_stmt (location_t, tree);
-extern tree objc_finish_try_stmt (void);
-extern void objc_begin_catch_clause (tree);
-extern void objc_finish_catch_clause (void);
-extern void objc_build_finally_clause (location_t, tree);
-extern tree objc_build_synchronized (location_t, tree, tree);
-extern int objc_static_init_needed_p (void);
-extern tree objc_generate_static_init_call (tree);
-extern tree objc_generate_write_barrier (tree, enum tree_code, tree);
-
-/* The following are provided by the C and C++ front-ends, and called by
- ObjC/ObjC++. */
-extern void *objc_get_current_scope (void);
-extern void objc_mark_locals_volatile (void *);
-
/* In c-ppoutput.c */
extern void init_pp_output (FILE *);
extern void preprocess_file (cpp_reader *);
extern tree c_finish_omp_critical (location_t, tree, tree);
extern tree c_finish_omp_ordered (location_t, tree);
extern void c_finish_omp_barrier (location_t);
-extern tree c_finish_omp_atomic (location_t, enum tree_code, tree, tree);
+extern tree c_finish_omp_atomic (location_t, enum tree_code, enum tree_code,
+ tree, tree, tree, tree, tree);
extern void c_finish_omp_flush (location_t);
extern void c_finish_omp_taskwait (location_t);
+extern void c_finish_omp_taskyield (location_t);
extern tree c_finish_omp_for (location_t, tree, tree, tree, tree, tree, tree);
extern void c_split_parallel_clauses (location_t, tree, tree *, tree *);
extern enum omp_clause_default_kind c_omp_predetermined_sharing (tree);
extern tree c_omp_remap_decl (tree, bool);
extern void record_types_used_by_current_var_decl (tree);
+/* Return next tree in the chain for chain_next walking of tree nodes. */
+static inline tree
+c_tree_chain_next (tree t)
+{
+ /* TREE_CHAIN of a type is TYPE_STUB_DECL, which is different
+ kind of object, never a long chain of nodes. Prefer
+ TYPE_NEXT_VARIANT for types. */
+ if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_TYPE_COMMON))
+ return TYPE_NEXT_VARIANT (t);
+ /* Otherwise, if there is TREE_CHAIN, return it. */
+ if (CODE_CONTAINS_STRUCT (TREE_CODE (t), TS_COMMON))
+ return TREE_CHAIN (t);
+ return NULL;
+}
+
#endif /* ! GCC_C_COMMON_H */