c-tree.h revision 117404
1257293Sneel/* Definitions for C parsing and type checking. 2257293Sneel Copyright (C) 1987, 1993, 1994, 1995, 1997, 1998, 3257293Sneel 1999, 2000, 2001, 2002 Free Software Foundation, Inc. 4257293Sneel 5257293SneelThis file is part of GCC. 6257293Sneel 7257293SneelGCC is free software; you can redistribute it and/or modify it under 8257293Sneelthe terms of the GNU General Public License as published by the Free 9257293SneelSoftware Foundation; either version 2, or (at your option) any later 10257293Sneelversion. 11257293Sneel 12257293SneelGCC is distributed in the hope that it will be useful, but WITHOUT ANY 13257293SneelWARRANTY; without even the implied warranty of MERCHANTABILITY or 14257293SneelFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15257293Sneelfor more details. 16257293Sneel 17257293SneelYou should have received a copy of the GNU General Public License 18257293Sneelalong with GCC; see the file COPYING. If not, write to the Free 19257293SneelSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA 20257293Sneel02111-1307, USA. */ 21257293Sneel 22257293Sneel#ifndef GCC_C_TREE_H 23257293Sneel#define GCC_C_TREE_H 24257293Sneel 25257293Sneel#include "c-common.h" 26257293Sneel 27257293Sneel/* Language-dependent contents of an identifier. */ 28257293Sneel 29257293Sneel/* The limbo_value is used for block level extern declarations, which need 30257293Sneel to be type checked against subsequent extern declarations. They can't 31257293Sneel be referenced after they fall out of scope, so they can't be global. 32257293Sneel 33257293Sneel The rid_code field is used for keywords. It is in all 34257293Sneel lang_identifier nodes, because some keywords are only special in a 35257293Sneel particular context. */ 36257293Sneel 37257293Sneelstruct lang_identifier GTY(()) 38257293Sneel{ 39259496Sgrehan struct c_common_identifier common_id; 40257293Sneel tree global_value; 41257293Sneel tree local_value; 42257293Sneel tree label_value; 43257293Sneel tree implicit_decl; 44257293Sneel tree error_locus; 45257293Sneel tree limbo_value; 46257293Sneel}; 47257293Sneel 48257293Sneel/* The resulting tree type. */ 49257293Sneel 50257293Sneelunion lang_tree_node 51257293Sneel GTY((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"), 52257293Sneel chain_next ("(union lang_tree_node *)TREE_CHAIN (&%h.generic)"))) 53257293Sneel{ 54257293Sneel union tree_node GTY ((tag ("0"), 55257293Sneel desc ("tree_node_structure (&%h)"))) 56257293Sneel generic; 57257293Sneel struct lang_identifier GTY ((tag ("1"))) identifier; 58257293Sneel}; 59257293Sneel 60257293Sneel/* Language-specific declaration information. */ 61257293Sneel 62257293Sneelstruct lang_decl GTY(()) 63257293Sneel{ 64257293Sneel struct c_lang_decl base; 65257293Sneel /* The return types and parameter types may have variable size. 66257293Sneel This is a list of any SAVE_EXPRs that need to be evaluated to 67257293Sneel compute those sizes. */ 68257293Sneel tree pending_sizes; 69257293Sneel}; 70257293Sneel 71259496Sgrehan/* Macros for access to language-specific slots in an identifier. */ 72257293Sneel/* Each of these slots contains a DECL node or null. */ 73257293Sneel 74257293Sneel/* This represents the value which the identifier has in the 75257293Sneel file-scope namespace. */ 76257293Sneel#define IDENTIFIER_GLOBAL_VALUE(NODE) \ 77257293Sneel (((struct lang_identifier *) (NODE))->global_value) 78257293Sneel/* This represents the value which the identifier has in the current 79257293Sneel scope. */ 80257293Sneel#define IDENTIFIER_LOCAL_VALUE(NODE) \ 81257293Sneel (((struct lang_identifier *) (NODE))->local_value) 82257293Sneel/* This represents the value which the identifier has as a label in 83257293Sneel the current label scope. */ 84257293Sneel#define IDENTIFIER_LABEL_VALUE(NODE) \ 85257293Sneel (((struct lang_identifier *) (NODE))->label_value) 86257293Sneel/* This records the extern decl of this identifier, if it has had one 87257293Sneel at any point in this compilation. */ 88257293Sneel#define IDENTIFIER_LIMBO_VALUE(NODE) \ 89257293Sneel (((struct lang_identifier *) (NODE))->limbo_value) 90257293Sneel/* This records the implicit function decl of this identifier, if it 91257293Sneel has had one at any point in this compilation. */ 92259496Sgrehan#define IDENTIFIER_IMPLICIT_DECL(NODE) \ 93259496Sgrehan (((struct lang_identifier *) (NODE))->implicit_decl) 94259496Sgrehan/* This is the last function in which we printed an "undefined variable" 95259496Sgrehan message for this identifier. Value is a FUNCTION_DECL or null. */ 96259496Sgrehan#define IDENTIFIER_ERROR_LOCUS(NODE) \ 97259496Sgrehan (((struct lang_identifier *) (NODE))->error_locus) 98257293Sneel 99257293Sneel/* In identifiers, C uses the following fields in a special way: 100257293Sneel TREE_PUBLIC to record that there was a previous local extern decl. 101257293Sneel TREE_USED to record that such a decl was used. 102257293Sneel TREE_ADDRESSABLE to record that the address of such a decl was used. */ 103257293Sneel 104257293Sneel/* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is read-only. */ 105257293Sneel#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1 (TYPE) 106257293Sneel 107257293Sneel/* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is volatile. */ 108257293Sneel#define C_TYPE_FIELDS_VOLATILE(TYPE) TREE_LANG_FLAG_2 (TYPE) 109257293Sneel 110257293Sneel/* In a RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE 111257293Sneel nonzero if the definition of the type has already started. */ 112257293Sneel#define C_TYPE_BEING_DEFINED(TYPE) TYPE_LANG_FLAG_0 (TYPE) 113257293Sneel 114259496Sgrehan/* In an IDENTIFIER_NODE, nonzero if this identifier is actually a 115257293Sneel keyword. C_RID_CODE (node) is then the RID_* value of the keyword, 116257293Sneel and C_RID_YYCODE is the token number wanted by Yacc. */ 117257293Sneel#define C_IS_RESERVED_WORD(ID) TREE_LANG_FLAG_0 (ID) 118257293Sneel 119257293Sneel/* This function was declared inline. This flag controls the linkage 120257293Sneel semantics of 'inline'; whether or not the function is inlined is 121257293Sneel controlled by DECL_INLINE. */ 122257293Sneel#define DECL_DECLARED_INLINE_P(NODE) \ 123257293Sneel (DECL_LANG_SPECIFIC (NODE)->base.declared_inline) 124257293Sneel 125257293Sneel/* In a RECORD_TYPE, a sorted array of the fields of the type. */ 126257293Sneelstruct lang_type GTY(()) 127257293Sneel{ 128259496Sgrehan int len; 129257293Sneel tree GTY((length ("%h.len"))) elts[1]; 130257293Sneel}; 131257293Sneel 132259496Sgrehan/* Record whether a type or decl was written with nonconstant size. 133257293Sneel Note that TYPE_SIZE may have simplified to a constant. */ 134257293Sneel#define C_TYPE_VARIABLE_SIZE(TYPE) TYPE_LANG_FLAG_1 (TYPE) 135259496Sgrehan#define C_DECL_VARIABLE_SIZE(TYPE) DECL_LANG_FLAG_0 (TYPE) 136257293Sneel 137259496Sgrehan#if 0 /* Not used. */ 138259496Sgrehan/* Record whether a decl for a function or function pointer has 139259496Sgrehan already been mentioned (in a warning) because it was called 140259496Sgrehan but didn't have a prototype. */ 141257293Sneel#define C_MISSING_PROTOTYPE_WARNED(DECL) DECL_LANG_FLAG_2 (DECL) 142259496Sgrehan#endif 143259496Sgrehan 144259496Sgrehan/* Store a value in that field. */ 145259496Sgrehan#define C_SET_EXP_ORIGINAL_CODE(EXP, CODE) \ 146257293Sneel (TREE_COMPLEXITY (EXP) = (int) (CODE)) 147257293Sneel 148257293Sneel/* Record whether a typedef for type `int' was actually `signed int'. */ 149259496Sgrehan#define C_TYPEDEF_EXPLICITLY_SIGNED(EXP) DECL_LANG_FLAG_1 (EXP) 150257293Sneel 151257293Sneel/* For a FUNCTION_DECL, nonzero if it was defined without an explicit 152257293Sneel return type. */ 153257293Sneel#define C_FUNCTION_IMPLICIT_INT(EXP) DECL_LANG_FLAG_1 (EXP) 154257293Sneel 155259496Sgrehan/* Nonzero for a declaration of a built in function if there has been no 156257293Sneel occasion that would declare the function in ordinary C. 157257293Sneel Using the function draws a pedantic warning in this case. */ 158259496Sgrehan#define C_DECL_ANTICIPATED(EXP) DECL_LANG_FLAG_3 (EXP) 159257293Sneel 160257293Sneel/* For FUNCTION_TYPE, a hidden list of types of arguments. The same as 161257293Sneel TYPE_ARG_TYPES for functions with prototypes, but created for functions 162257293Sneel without prototypes. */ 163257293Sneel#define TYPE_ACTUAL_ARG_TYPES(NODE) TYPE_BINFO (NODE) 164257293Sneel 165257293Sneel 166259496Sgrehan/* in c-lang.c and objc-act.c */ 167257293Sneelextern tree lookup_interface PARAMS ((tree)); 168257293Sneelextern tree is_class_name PARAMS ((tree)); 169257293Sneelextern tree objc_is_id PARAMS ((tree)); 170259496Sgrehanextern void objc_check_decl PARAMS ((tree)); 171259496Sgrehanextern void finish_file PARAMS ((void)); 172257293Sneelextern int objc_comptypes PARAMS ((tree, tree, int)); 173257293Sneelextern tree objc_message_selector PARAMS ((void)); 174257293Sneelextern tree lookup_objc_ivar PARAMS ((tree)); 175257293Sneel 176257293Sneel 177257293Sneel/* in c-parse.in */ 178257293Sneelextern void c_parse_init PARAMS ((void)); 179259496Sgrehan 180257293Sneel/* in c-aux-info.c */ 181257293Sneelextern void gen_aux_info_record PARAMS ((tree, int, int, int)); 182259496Sgrehan 183257293Sneel/* in c-decl.c */ 184257293Sneelextern int global_bindings_p PARAMS ((void)); 185257293Sneelextern int kept_level_p PARAMS ((void)); 186257293Sneelextern tree getdecls PARAMS ((void)); 187257293Sneelextern void pushlevel PARAMS ((int)); 188257293Sneelextern tree poplevel PARAMS ((int,int, int)); 189257293Sneelextern void insert_block PARAMS ((tree)); 190257293Sneelextern void set_block PARAMS ((tree)); 191257293Sneelextern tree pushdecl PARAMS ((tree)); 192257293Sneel 193257293Sneelextern void c_insert_default_attributes PARAMS ((tree)); 194257293Sneelextern void c_init_decl_processing PARAMS ((void)); 195257293Sneelextern void c_dup_lang_specific_decl PARAMS ((tree)); 196257293Sneelextern void c_print_identifier PARAMS ((FILE *, tree, int)); 197257293Sneelextern tree build_array_declarator PARAMS ((tree, tree, int, int)); 198257293Sneelextern tree build_enumerator PARAMS ((tree, tree)); 199257293Sneelextern void check_for_loop_decls PARAMS ((void)); 200257293Sneelextern void clear_parm_order PARAMS ((void)); 201257293Sneelextern int complete_array_type PARAMS ((tree, tree, int)); 202257293Sneelextern void declare_parm_level PARAMS ((int)); 203257293Sneelextern tree define_label PARAMS ((const char *, int, 204257293Sneel tree)); 205257293Sneelextern void finish_decl PARAMS ((tree, tree, tree)); 206257293Sneelextern tree finish_enum PARAMS ((tree, tree, tree)); 207257293Sneelextern void finish_function PARAMS ((int, int)); 208257293Sneelextern tree finish_struct PARAMS ((tree, tree, tree)); 209257293Sneelextern tree get_parm_info PARAMS ((int)); 210257293Sneelextern tree grokfield PARAMS ((const char *, int, tree, tree, tree)); 211257293Sneelextern tree groktypename PARAMS ((tree)); 212257293Sneelextern tree groktypename_in_parm_context PARAMS ((tree)); 213257293Sneelextern tree implicitly_declare PARAMS ((tree)); 214257293Sneelextern void implicit_decl_warning PARAMS ((tree)); 215257293Sneelextern int in_parm_level_p PARAMS ((void)); 216257293Sneelextern void keep_next_level PARAMS ((void)); 217257293Sneelextern tree lookup_name PARAMS ((tree)); 218257293Sneelextern tree lookup_name_current_level PARAMS ((tree)); 219257293Sneelextern void parmlist_tags_warning PARAMS ((void)); 220257293Sneelextern void pending_xref_error PARAMS ((void)); 221257293Sneelextern void c_push_function_context PARAMS ((struct function *)); 222257293Sneelextern void c_pop_function_context PARAMS ((struct function *)); 223257293Sneelextern void pop_label_level PARAMS ((void)); 224257293Sneelextern void push_label_level PARAMS ((void)); 225257293Sneelextern void push_parm_decl PARAMS ((tree)); 226257293Sneelextern tree pushdecl_top_level PARAMS ((tree)); 227257293Sneelextern void pushtag PARAMS ((tree, tree)); 228257293Sneelextern tree set_array_declarator_type PARAMS ((tree, tree, int)); 229257293Sneelextern tree shadow_label PARAMS ((tree)); 230257293Sneelextern void shadow_tag PARAMS ((tree)); 231257293Sneelextern void shadow_tag_warned PARAMS ((tree, int)); 232257293Sneelextern tree start_enum PARAMS ((tree)); 233257293Sneelextern int start_function PARAMS ((tree, tree, tree)); 234257293Sneelextern tree start_decl PARAMS ((tree, tree, int, 235257293Sneel tree)); 236257293Sneelextern tree start_struct PARAMS ((enum tree_code, tree)); 237257293Sneelextern void store_parm_decls PARAMS ((void)); 238257293Sneelextern tree xref_tag PARAMS ((enum tree_code, tree)); 239259496Sgrehanextern tree c_begin_compound_stmt PARAMS ((void)); 240259496Sgrehanextern void c_expand_deferred_function PARAMS ((tree)); 241257293Sneelextern void c_expand_decl_stmt PARAMS ((tree)); 242257293Sneelextern tree make_pointer_declarator PARAMS ((tree, tree)); 243257293Sneel 244257293Sneel/* in c-objc-common.c */ 245257293Sneelextern int c_disregard_inline_limits PARAMS ((tree)); 246257293Sneelextern int c_cannot_inline_tree_fn PARAMS ((tree *)); 247257293Sneelextern const char *c_objc_common_init PARAMS ((const char *)); 248257293Sneelextern int c_missing_noreturn_ok_p PARAMS ((tree)); 249257293Sneelextern void c_objc_common_finish_file PARAMS ((void)); 250257293Sneelextern int defer_fn PARAMS ((tree)); 251257293Sneelextern bool c_warn_unused_global_decl PARAMS ((tree)); 252257293Sneel 253257293Sneel#define c_build_type_variant(TYPE, CONST_P, VOLATILE_P) \ 254257293Sneel c_build_qualified_type ((TYPE), \ 255257293Sneel ((CONST_P) ? TYPE_QUAL_CONST : 0) | \ 256257293Sneel ((VOLATILE_P) ? TYPE_QUAL_VOLATILE : 0)) 257257293Sneel 258257293Sneel#define c_sizeof_nowarn(T) c_sizeof_or_alignof_type (T, SIZEOF_EXPR, 0) 259257293Sneel/* in c-typeck.c */ 260257293Sneelextern tree require_complete_type PARAMS ((tree)); 261257293Sneelextern int comptypes PARAMS ((tree, tree)); 262257293Sneelextern tree c_size_in_bytes PARAMS ((tree)); 263257293Sneelextern bool c_mark_addressable PARAMS ((tree)); 264257293Sneelextern void c_incomplete_type_error PARAMS ((tree, tree)); 265257293Sneelextern tree c_type_promotes_to PARAMS ((tree)); 266257293Sneelextern tree build_component_ref PARAMS ((tree, tree)); 267257293Sneelextern tree build_indirect_ref PARAMS ((tree, const char *)); 268257293Sneelextern tree build_array_ref PARAMS ((tree, tree)); 269257293Sneelextern tree build_external_ref PARAMS ((tree, int)); 270257293Sneelextern tree parser_build_binary_op PARAMS ((enum tree_code, 271257293Sneel tree, tree)); 272257293Sneelextern int c_tree_expr_nonnegative_p PARAMS ((tree)); 273257293Sneelextern void readonly_warning PARAMS ((tree, const char *)); 274257293Sneelextern tree build_conditional_expr PARAMS ((tree, tree, tree)); 275257293Sneelextern tree build_compound_expr PARAMS ((tree)); 276257293Sneelextern tree c_cast_expr PARAMS ((tree, tree)); 277257293Sneelextern tree build_c_cast PARAMS ((tree, tree)); 278257293Sneelextern tree build_modify_expr PARAMS ((tree, enum tree_code, 279257293Sneel tree)); 280257293Sneelextern void store_init_value PARAMS ((tree, tree)); 281257293Sneelextern void error_init PARAMS ((const char *)); 282257293Sneelextern void pedwarn_init PARAMS ((const char *)); 283257293Sneelextern void start_init PARAMS ((tree, tree, int)); 284257293Sneelextern void finish_init PARAMS ((void)); 285257293Sneelextern void really_start_incremental_init PARAMS ((tree)); 286257293Sneelextern void push_init_level PARAMS ((int)); 287257293Sneelextern tree pop_init_level PARAMS ((int)); 288257293Sneelextern void set_init_index PARAMS ((tree, tree)); 289257293Sneelextern void set_init_label PARAMS ((tree)); 290257293Sneelextern void process_init_element PARAMS ((tree)); 291257293Sneelextern tree build_compound_literal PARAMS ((tree, tree)); 292257293Sneelextern void pedwarn_c99 PARAMS ((const char *, ...)) 293257293Sneel ATTRIBUTE_PRINTF_1; 294257293Sneelextern tree c_start_case PARAMS ((tree)); 295257293Sneelextern void c_finish_case PARAMS ((void)); 296257293Sneelextern tree simple_asm_stmt PARAMS ((tree)); 297257293Sneelextern tree build_asm_stmt PARAMS ((tree, tree, tree, 298257293Sneel tree, tree)); 299257293Sneelextern tree c_convert_parm_for_inlining PARAMS ((tree, tree, tree)); 300257293Sneel 301257293Sneel/* Set to 0 at beginning of a function definition, set to 1 if 302257293Sneel a return statement that specifies a return value is seen. */ 303257293Sneel 304257293Sneelextern int current_function_returns_value; 305259496Sgrehan 306257293Sneel/* Set to 0 at beginning of a function definition, set to 1 if 307257293Sneel a return statement with no argument is seen. */ 308257293Sneel 309257293Sneelextern int current_function_returns_null; 310257293Sneel 311257293Sneel/* Set to 0 at beginning of a function definition, set to 1 if 312257293Sneel a call to a noreturn function is seen. */ 313257293Sneel 314257293Sneelextern int current_function_returns_abnormally; 315257293Sneel 316259496Sgrehan/* Nonzero means we are reading code that came from a system header file. */ 317257293Sneel 318257293Sneelextern int system_header_p; 319259496Sgrehan 320257293Sneel/* In c-decl.c */ 321257293Sneelextern void c_finish_incomplete_decl PARAMS ((tree)); 322257293Sneel 323257293Sneelextern GTY(()) tree static_ctors; 324257293Sneelextern GTY(()) tree static_dtors; 325257293Sneel 326257293Sneel#endif /* ! GCC_C_TREE_H */ 327257293Sneel