c-tree.h revision 37654
178344Sobrien/* Definitions for C parsing and type checking. 278344Sobrien Copyright (C) 1987, 1993, 1994, 1995 Free Software Foundation, Inc. 398184Sgordon 498184SgordonThis file is part of GNU CC. 578344Sobrien 678344SobrienGNU CC is free software; you can redistribute it and/or modify 778344Sobrienit under the terms of the GNU General Public License as published by 8140339Sobrienthe Free Software Foundation; either version 2, or (at your option) 998184Sgordonany later version. 1078344Sobrien 1178344SobrienGNU CC is distributed in the hope that it will be useful, 1278344Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of 1378344SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1498184SgordonGNU General Public License for more details. 1578344Sobrien 1678344SobrienYou should have received a copy of the GNU General Public License 1778344Sobrienalong with GNU CC; see the file COPYING. If not, write to 1878344Sobrienthe Free Software Foundation, 59 Temple Place - Suite 330, 1978344SobrienBoston, MA 02111-1307, USA. */ 20165664Syar 21159833Sflz#ifndef _C_TREE_H 22124618Smtm#define _C_TREE_H 23124618Smtm 24124618Smtm/* Language-dependent contents of an identifier. */ 25124618Smtm 26124618Smtm/* The limbo_value is used for block level extern declarations, which need 27154114Sdougb to be type checked against subsequent extern declarations. They can't 28154114Sdougb be referenced after they fall out of scope, so they can't be global. */ 29159833Sflz 30159833Sflzstruct lang_identifier 31159833Sflz{ 32159833Sflz struct tree_identifier ignore; 33154114Sdougb tree global_value, local_value, label_value, implicit_decl; 34154114Sdougb tree error_locus, limbo_value; 35124618Smtm}; 36124618Smtm 37124618Smtm/* Macros for access to language-specific slots in an identifier. */ 38124618Smtm/* Each of these slots contains a DECL node or null. */ 39124618Smtm 40124618Smtm/* This represents the value which the identifier has in the 41124618Smtm file-scope namespace. */ 42124618Smtm#define IDENTIFIER_GLOBAL_VALUE(NODE) \ 43154114Sdougb (((struct lang_identifier *)(NODE))->global_value) 44154114Sdougb/* This represents the value which the identifier has in the current 45154114Sdougb scope. */ 46154114Sdougb#define IDENTIFIER_LOCAL_VALUE(NODE) \ 47159833Sflz (((struct lang_identifier *)(NODE))->local_value) 48159833Sflz/* This represents the value which the identifier has as a label in 49159833Sflz the current label scope. */ 50159833Sflz#define IDENTIFIER_LABEL_VALUE(NODE) \ 51154114Sdougb (((struct lang_identifier *)(NODE))->label_value) 52154114Sdougb/* This records the extern decl of this identifier, if it has had one 53154114Sdougb at any point in this compilation. */ 54154114Sdougb#define IDENTIFIER_LIMBO_VALUE(NODE) \ 55154114Sdougb (((struct lang_identifier *)(NODE))->limbo_value) 56154114Sdougb/* This records the implicit function decl of this identifier, if it 57154114Sdougb has had one at any point in this compilation. */ 58124618Smtm#define IDENTIFIER_IMPLICIT_DECL(NODE) \ 59124618Smtm (((struct lang_identifier *)(NODE))->implicit_decl) 60124618Smtm/* This is the last function in which we printed an "undefined variable" 61124618Smtm message for this identifier. Value is a FUNCTION_DECL or null. */ 62124618Smtm#define IDENTIFIER_ERROR_LOCUS(NODE) \ 63124618Smtm (((struct lang_identifier *)(NODE))->error_locus) 64124618Smtm 65117077Strhodes/* In identifiers, C uses the following fields in a special way: 66103436Speter TREE_PUBLIC to record that there was a previous local extern decl. 67103436Speter TREE_USED to record that such a decl was used. 68103436Speter TREE_ADDRESSABLE to record that the address of such a decl was used. */ 69124618Smtm 70124618Smtm/* Nonzero means reject anything that ANSI standard C forbids. */ 71124618Smtmextern int pedantic; 72124618Smtm 73124618Smtm/* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is read-only. */ 7478344Sobrien#define C_TYPE_FIELDS_READONLY(type) TREE_LANG_FLAG_1 (type) 7578344Sobrien 7678344Sobrien/* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is volatile. */ 7778344Sobrien#define C_TYPE_FIELDS_VOLATILE(type) TREE_LANG_FLAG_2 (type) 78 79/* In a RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE 80 nonzero if the definition of the type has already started. */ 81#define C_TYPE_BEING_DEFINED(type) TYPE_LANG_FLAG_0 (type) 82 83/* In a RECORD_TYPE, a sorted array of the fields of the type. */ 84struct lang_type 85{ 86 int len; 87 tree elts[1]; 88}; 89 90/* Mark which labels are explicitly declared. 91 These may be shadowed, and may be referenced from nested functions. */ 92#define C_DECLARED_LABEL_FLAG(label) TREE_LANG_FLAG_1 (label) 93 94/* Record whether a type or decl was written with nonconstant size. 95 Note that TYPE_SIZE may have simplified to a constant. */ 96#define C_TYPE_VARIABLE_SIZE(type) TYPE_LANG_FLAG_1 (type) 97#define C_DECL_VARIABLE_SIZE(type) DECL_LANG_FLAG_0 (type) 98 99/* Record in each node resulting from a binary operator 100 what operator was specified for it. */ 101#define C_EXP_ORIGINAL_CODE(exp) ((enum tree_code) TREE_COMPLEXITY (exp)) 102 103#if 0 /* Not used. */ 104/* Record whether a decl for a function or function pointer has 105 already been mentioned (in a warning) because it was called 106 but didn't have a prototype. */ 107#define C_MISSING_PROTOTYPE_WARNED(decl) DECL_LANG_FLAG_2(decl) 108#endif 109 110/* Store a value in that field. */ 111#define C_SET_EXP_ORIGINAL_CODE(exp, code) \ 112 (TREE_COMPLEXITY (exp) = (int)(code)) 113 114/* Record whether a typedef for type `int' was actually `signed int'. */ 115#define C_TYPEDEF_EXPLICITLY_SIGNED(exp) DECL_LANG_FLAG_1 ((exp)) 116 117/* Nonzero for a declaration of a built in function if there has been no 118 occasion that would declare the function in ordinary C. 119 Using the function draws a pedantic warning in this case. */ 120#define C_DECL_ANTICIPATED(exp) DECL_LANG_FLAG_3 ((exp)) 121 122/* For FUNCTION_TYPE, a hidden list of types of arguments. The same as 123 TYPE_ARG_TYPES for functions with prototypes, but created for functions 124 without prototypes. */ 125#define TYPE_ACTUAL_ARG_TYPES(NODE) TYPE_NONCOPIED_PARTS (NODE) 126 127/* Nonzero if the type T promotes to itself. 128 ANSI C states explicitly the list of types that promote; 129 in particular, short promotes to int even if they have the same width. */ 130#define C_PROMOTING_INTEGER_TYPE_P(t) \ 131 (TREE_CODE ((t)) == INTEGER_TYPE \ 132 && (TYPE_MAIN_VARIANT (t) == char_type_node \ 133 || TYPE_MAIN_VARIANT (t) == signed_char_type_node \ 134 || TYPE_MAIN_VARIANT (t) == unsigned_char_type_node \ 135 || TYPE_MAIN_VARIANT (t) == short_integer_type_node \ 136 || TYPE_MAIN_VARIANT (t) == short_unsigned_type_node)) 137 138/* In a VAR_DECL, means the variable is really an iterator. */ 139#define ITERATOR_P(D) (DECL_LANG_FLAG_4(D)) 140 141/* In a VAR_DECL for an iterator, means we are within 142 an explicit loop over that iterator. */ 143#define ITERATOR_BOUND_P(NODE) ((NODE)->common.readonly_flag) 144 145/* in c-lang.c and objc-act.c */ 146extern tree lookup_interface PROTO((tree)); 147extern tree is_class_name PROTO((tree)); 148extern void maybe_objc_check_decl PROTO((tree)); 149extern int maybe_objc_comptypes PROTO((tree, tree, int)); 150extern tree maybe_building_objc_message_expr PROTO((void)); 151extern tree maybe_objc_method_name PROTO((tree)); 152extern int recognize_objc_keyword PROTO((void)); 153extern tree build_objc_string PROTO((int, char *)); 154 155/* in c-aux-info.c */ 156extern void gen_aux_info_record PROTO((tree, int, int, int)); 157 158/* in c-common.c */ 159extern void declare_function_name PROTO((void)); 160extern void decl_attributes PROTO((tree, tree, tree)); 161extern void init_function_format_info PROTO((void)); 162extern void record_function_format PROTO((tree, tree, int, int, int, int)); 163extern void check_function_format PROTO((tree, tree, tree)); 164/* Print an error message for invalid operands to arith operation CODE. 165 NOP_EXPR is used as a special case (see truthvalue_conversion). */ 166extern void binary_op_error PROTO((enum tree_code)); 167extern void c_expand_expr_stmt PROTO((tree)); 168/* Validate the expression after `case' and apply default promotions. */ 169extern tree check_case_value PROTO((tree)); 170/* Concatenate a list of STRING_CST nodes into one STRING_CST. */ 171extern tree combine_strings PROTO((tree)); 172extern void constant_expression_warning PROTO((tree)); 173extern tree convert_and_check PROTO((tree, tree)); 174extern void overflow_warning PROTO((tree)); 175extern void unsigned_conversion_warning PROTO((tree, tree)); 176/* Read the rest of the current #-directive line. */ 177extern char *get_directive_line STDIO_PROTO((FILE *)); 178/* Subroutine of build_binary_op, used for comparison operations. 179 See if the operands have both been converted from subword integer types 180 and, if so, perhaps change them both back to their original type. */ 181extern tree shorten_compare PROTO((tree *, tree *, tree *, enum tree_code *)); 182/* Prepare expr to be an argument of a TRUTH_NOT_EXPR, 183 or validate its data type for an `if' or `while' statement or ?..: exp. */ 184extern tree truthvalue_conversion PROTO((tree)); 185extern tree type_for_mode PROTO((enum machine_mode, int)); 186extern tree type_for_size PROTO((unsigned, int)); 187 188/* in c-convert.c */ 189extern tree convert PROTO((tree, tree)); 190 191/* in c-decl.c */ 192/* Standard named or nameless data types of the C compiler. */ 193extern tree char_array_type_node; 194extern tree char_type_node; 195extern tree const_ptr_type_node; 196extern tree const_string_type_node; 197extern tree default_function_type; 198extern tree double_ftype_double; 199extern tree double_ftype_double_double; 200extern tree double_type_node; 201extern tree float_type_node; 202extern tree intDI_type_node; 203extern tree intHI_type_node; 204extern tree intQI_type_node; 205extern tree intSI_type_node; 206extern tree int_array_type_node; 207extern tree int_ftype_cptr_cptr_sizet; 208extern tree int_ftype_int; 209extern tree int_ftype_ptr_ptr_int; 210extern tree int_ftype_string_string; 211extern tree integer_type_node; 212extern tree long_double_type_node; 213extern tree long_ftype_long; 214extern tree long_integer_type_node; 215extern tree long_long_integer_type_node; 216extern tree long_long_unsigned_type_node; 217extern tree long_unsigned_type_node; 218extern tree complex_integer_type_node; 219extern tree complex_float_type_node; 220extern tree complex_double_type_node; 221extern tree complex_long_double_type_node; 222extern tree ptr_type_node; 223extern tree ptrdiff_type_node; 224extern tree short_integer_type_node; 225extern tree short_unsigned_type_node; 226extern tree signed_char_type_node; 227extern tree signed_wchar_type_node; 228extern tree string_ftype_ptr_ptr; 229extern tree string_type_node; 230extern tree unsigned_char_type_node; 231extern tree unsigned_intDI_type_node; 232extern tree unsigned_intHI_type_node; 233extern tree unsigned_intQI_type_node; 234extern tree unsigned_intSI_type_node; 235extern tree unsigned_type_node; 236extern tree unsigned_wchar_type_node; 237extern tree void_ftype_ptr_int_int; 238extern tree void_ftype_ptr_ptr_int; 239extern tree void_type_node; 240extern tree wchar_array_type_node; 241extern tree wchar_type_node; 242extern tree boolean_type_node; 243extern tree boolean_true_node; 244extern tree boolean_false_node; 245 246extern tree build_enumerator PROTO((tree, tree)); 247/* Declare a predefined function. Return the declaration. */ 248extern tree builtin_function PROTO((char *, tree, enum built_in_function function_, char *)); 249/* Add qualifiers to a type, in the fashion for C. */ 250extern tree c_build_type_variant PROTO((tree, int, int)); 251extern int c_decode_option PROTO((char *)); 252extern void c_mark_varargs PROTO((void)); 253extern tree check_identifier PROTO((tree, tree)); 254extern void clear_parm_order PROTO((void)); 255extern tree combine_parm_decls PROTO((tree, tree, int)); 256extern int complete_array_type PROTO((tree, tree, int)); 257extern void declare_parm_level PROTO((int)); 258extern tree define_label PROTO((char *, int, tree)); 259extern void delete_block PROTO((tree)); 260extern void finish_decl PROTO((tree, tree, tree)); 261extern void finish_decl_top_level PROTO((tree, tree, tree)); 262extern tree finish_enum PROTO((tree, tree, tree)); 263extern void finish_function PROTO((int)); 264extern tree finish_struct PROTO((tree, tree, tree)); 265extern tree get_parm_info PROTO((int)); 266extern tree getdecls PROTO((void)); 267extern tree gettags PROTO((void)); 268extern int global_bindings_p PROTO((void)); 269extern tree grokfield PROTO((char *, int, tree, tree, tree)); 270extern tree groktypename PROTO((tree)); 271extern tree groktypename_in_parm_context PROTO((tree)); 272extern tree implicitly_declare PROTO((tree)); 273extern int in_parm_level_p PROTO((void)); 274extern void init_decl_processing PROTO((void)); 275extern void insert_block PROTO((tree)); 276extern void keep_next_level PROTO((void)); 277extern int kept_level_p PROTO((void)); 278extern tree lookup_label PROTO((tree)); 279extern tree lookup_name PROTO((tree)); 280extern tree lookup_name_current_level PROTO((tree)); 281extern tree lookup_name_current_level_global PROTO((tree)); 282extern tree maybe_build_cleanup PROTO((tree)); 283extern void parmlist_tags_warning PROTO((void)); 284extern void pending_xref_error PROTO((void)); 285extern void pop_c_function_context PROTO((void)); 286extern void pop_label_level PROTO((void)); 287extern tree poplevel PROTO((int, int, int)); 288extern void print_lang_decl STDIO_PROTO((FILE *, tree, 289 int)); 290extern void print_lang_identifier STDIO_PROTO((FILE *, tree, 291 int)); 292extern void print_lang_type STDIO_PROTO((FILE *, tree, 293 int)); 294extern void push_c_function_context PROTO((void)); 295extern void push_label_level PROTO((void)); 296extern void push_parm_decl PROTO((tree)); 297extern tree pushdecl PROTO((tree)); 298extern tree pushdecl_top_level PROTO((tree)); 299extern void pushlevel PROTO((int)); 300extern void pushtag PROTO((tree, tree)); 301extern void set_block PROTO((tree)); 302extern tree shadow_label PROTO((tree)); 303extern void shadow_record_fields PROTO((tree)); 304extern void shadow_tag PROTO((tree)); 305extern void shadow_tag_warned PROTO((tree, int)); 306extern tree start_enum PROTO((tree)); 307extern int start_function PROTO((tree, tree, tree, 308 tree, int)); 309extern tree start_decl PROTO((tree, tree, int, 310 tree, tree)); 311extern tree start_struct PROTO((enum tree_code, tree)); 312extern void store_parm_decls PROTO((void)); 313extern tree xref_tag PROTO((enum tree_code, tree)); 314 315/* in c-typeck.c */ 316extern tree require_complete_type PROTO((tree)); 317extern void incomplete_type_error PROTO((tree, tree)); 318/* Given two integer or real types, return the type for their sum. 319 Given two compatible ANSI C types, returns the merged type. */ 320extern tree common_type PROTO((tree, tree)); 321extern int comptypes PROTO((tree, tree)); 322extern int self_promoting_args_p PROTO((tree)); 323extern tree c_sizeof PROTO((tree)); 324extern tree c_sizeof_nowarn PROTO((tree)); 325extern tree c_size_in_bytes PROTO((tree)); 326extern tree c_alignof PROTO((tree)); 327extern tree c_alignof_expr PROTO((tree)); 328extern tree default_conversion PROTO((tree)); 329extern tree build_component_ref PROTO((tree, tree)); 330extern tree build_indirect_ref PROTO((tree, char *)); 331extern tree build_array_ref PROTO((tree, tree)); 332extern tree build_function_call PROTO((tree, tree)); 333extern tree parser_build_binary_op PROTO((enum tree_code, 334 tree, tree)); 335extern tree build_binary_op PROTO((enum tree_code, 336 tree, tree, int)); 337extern tree build_unary_op PROTO((enum tree_code, 338 tree, int)); 339extern int lvalue_p PROTO((tree)); 340extern int lvalue_or_else PROTO((tree, char *)); 341extern void readonly_warning PROTO((tree, char *)); 342extern int mark_addressable PROTO((tree)); 343extern tree build_conditional_expr PROTO((tree, tree, tree)); 344extern tree build_compound_expr PROTO((tree)); 345extern tree build_c_cast PROTO((tree, tree)); 346extern tree build_modify_expr PROTO((tree, enum tree_code, 347 tree)); 348extern tree initializer_constant_valid_p PROTO((tree, tree)); 349extern void store_init_value PROTO((tree, tree)); 350extern void error_init PROTO((char *, char *, 351 char *)); 352extern void pedwarn_init PROTO((char *, char *, 353 char *)); 354extern void start_init PROTO((tree, tree, int)); 355extern void finish_init PROTO((void)); 356extern void really_start_incremental_init PROTO((tree)); 357extern void push_init_level PROTO((int)); 358extern tree pop_init_level PROTO((int)); 359extern void set_init_index PROTO((tree, tree)); 360extern void set_init_label PROTO((tree)); 361extern void process_init_element PROTO((tree)); 362extern void c_expand_asm_operands PROTO((tree, tree, tree, tree, 363 int, char *, int)); 364extern void c_expand_return PROTO((tree)); 365extern tree c_expand_start_case PROTO((tree)); 366 367/* in c-iterate.c */ 368extern void iterator_expand PROTO((tree)); 369extern void iterator_for_loop_start PROTO((tree)); 370extern void iterator_for_loop_end PROTO((tree)); 371extern void iterator_for_loop_record PROTO((tree)); 372extern void push_iterator_stack PROTO((void)); 373extern void pop_iterator_stack PROTO((void)); 374 375/* Set to 0 at beginning of a function definition, set to 1 if 376 a return statement that specifies a return value is seen. */ 377 378extern int current_function_returns_value; 379 380/* Set to 0 at beginning of a function definition, set to 1 if 381 a return statement with no argument is seen. */ 382 383extern int current_function_returns_null; 384 385/* Nonzero means `$' can be in an identifier. */ 386 387extern int dollars_in_ident; 388 389/* Nonzero means allow type mismatches in conditional expressions; 390 just make their values `void'. */ 391 392extern int flag_cond_mismatch; 393 394/* Nonzero means don't recognize the keyword `asm'. */ 395 396extern int flag_no_asm; 397 398/* Nonzero means ignore `#ident' directives. */ 399 400extern int flag_no_ident; 401 402/* Nonzero means warn about implicit declarations. */ 403 404extern int warn_implicit; 405 406/* Nonzero means give string constants the type `const char *' 407 to get extra warnings from them. These warnings will be too numerous 408 to be useful, except in thoroughly ANSIfied programs. */ 409 410extern int warn_write_strings; 411 412/* Nonzero means warn about sizeof (function) or addition/subtraction 413 of function pointers. */ 414 415extern int warn_pointer_arith; 416 417/* Nonzero means warn for all old-style non-prototype function decls. */ 418 419extern int warn_strict_prototypes; 420 421/* Nonzero means warn about multiple (redundant) decls for the same single 422 variable or function. */ 423 424extern int warn_redundant_decls; 425 426/* Nonzero means warn about extern declarations of objects not at 427 file-scope level and about *all* declarations of functions (whether 428 extern or static) not at file-scope level. Note that we exclude 429 implicit function declarations. To get warnings about those, use 430 -Wimplicit. */ 431 432extern int warn_nested_externs; 433 434/* Nonzero means warn about pointer casts that can drop a type qualifier 435 from the pointer target type. */ 436 437extern int warn_cast_qual; 438 439/* Nonzero means warn when casting a function call to a type that does 440 not match the return type (e.g. (float)sqrt() or (anything*)malloc() 441 when there is no previous declaration of sqrt or malloc. */ 442 443extern int warn_bad_function_cast; 444 445/* Warn about traditional constructs whose meanings changed in ANSI C. */ 446 447extern int warn_traditional; 448 449/* Warn about *printf or *scanf format/argument anomalies. */ 450 451extern int warn_format; 452 453/* Warn about a subscript that has type char. */ 454 455extern int warn_char_subscripts; 456 457/* Warn if a type conversion is done that might have confusing results. */ 458 459extern int warn_conversion; 460 461/* Nonzero means do some things the same way PCC does. */ 462 463extern int flag_traditional; 464 465/* Nonzero means to allow single precision math even if we're generally 466 being traditional. */ 467extern int flag_allow_single_precision; 468 469/* Nonzero means warn about suggesting putting in ()'s. */ 470 471extern int warn_parentheses; 472 473/* Warn if initializer is not completely bracketed. */ 474 475extern int warn_missing_braces; 476 477/* Nonzero means this is a function to call to perform comptypes 478 on two record types. */ 479 480extern int (*comptypes_record_hook) (); 481 482/* Nonzero means we are reading code that came from a system header file. */ 483 484extern int system_header_p; 485 486/* Nonzero enables objc features. */ 487 488extern int doing_objc_thang; 489 490#endif /* not _C_TREE_H */ 491