Mercurial > hg > CbC > CbC_gcc
comparison gcc/c-tree.h @ 69:1b10fe6932e1
merge 69
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 21 Aug 2011 07:53:12 +0900 |
parents | 326d9e06c2e3 f6334be47118 |
children | b81903832de2 |
comparison
equal
deleted
inserted
replaced
66:b362627d71ba | 69:1b10fe6932e1 |
---|---|
1 /* Definitions for C parsing and type checking. | 1 /* Definitions for C parsing and type checking. |
2 Copyright (C) 1987, 1993, 1994, 1995, 1997, 1998, | 2 Copyright (C) 1987, 1993, 1994, 1995, 1997, 1998, |
3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009 | 3 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 |
4 Free Software Foundation, Inc. | 4 Free Software Foundation, Inc. |
5 | 5 |
6 This file is part of GCC. | 6 This file is part of GCC. |
7 | 7 |
8 GCC is free software; you can redistribute it and/or modify it under | 8 GCC is free software; you can redistribute it and/or modify it under |
20 <http://www.gnu.org/licenses/>. */ | 20 <http://www.gnu.org/licenses/>. */ |
21 | 21 |
22 #ifndef GCC_C_TREE_H | 22 #ifndef GCC_C_TREE_H |
23 #define GCC_C_TREE_H | 23 #define GCC_C_TREE_H |
24 | 24 |
25 #include "c-common.h" | 25 #include "c-family/c-common.h" |
26 #include "toplev.h" | |
27 #include "diagnostic.h" | 26 #include "diagnostic.h" |
28 | 27 |
29 /* struct lang_identifier is private to c-decl.c, but langhooks.c needs to | 28 /* struct lang_identifier is private to c-decl.c, but langhooks.c needs to |
30 know how big it is. This is sanity-checked in c-decl.c. */ | 29 know how big it is. This is sanity-checked in c-decl.c. */ |
31 #define C_SIZEOF_STRUCT_LANG_IDENTIFIER \ | 30 #define C_SIZEOF_STRUCT_LANG_IDENTIFIER \ |
95 #define C_DECL_THREADPRIVATE_P(DECL) DECL_LANG_FLAG_3 (VAR_DECL_CHECK (DECL)) | 94 #define C_DECL_THREADPRIVATE_P(DECL) DECL_LANG_FLAG_3 (VAR_DECL_CHECK (DECL)) |
96 | 95 |
97 /* Nonzero for a decl which either doesn't exist or isn't a prototype. | 96 /* Nonzero for a decl which either doesn't exist or isn't a prototype. |
98 N.B. Could be simplified if all built-in decls had complete prototypes | 97 N.B. Could be simplified if all built-in decls had complete prototypes |
99 (but this is presently difficult because some of them need FILE*). */ | 98 (but this is presently difficult because some of them need FILE*). */ |
100 #define C_DECL_ISNT_PROTOTYPE(EXP) \ | 99 #define C_DECL_ISNT_PROTOTYPE(EXP) \ |
101 (EXP == 0 \ | 100 (EXP == 0 \ |
102 || (TYPE_ARG_TYPES (TREE_TYPE (EXP)) == 0 \ | 101 || (!prototype_p (TREE_TYPE (EXP)) \ |
103 && !DECL_BUILT_IN (EXP))) | 102 && !DECL_BUILT_IN (EXP))) |
104 | 103 |
105 /* For FUNCTION_TYPE, a hidden list of types of arguments. The same as | 104 /* For FUNCTION_TYPE, a hidden list of types of arguments. The same as |
106 TYPE_ARG_TYPES for functions with prototypes, but created for functions | 105 TYPE_ARG_TYPES for functions with prototypes, but created for functions |
107 without prototypes. */ | 106 without prototypes. */ |
108 #define TYPE_ACTUAL_ARG_TYPES(NODE) TYPE_LANG_SLOT_1 (NODE) | 107 #define TYPE_ACTUAL_ARG_TYPES(NODE) TYPE_LANG_SLOT_1 (NODE) |
133 | 132 |
134 /* A kind of type specifier. Note that this information is currently | 133 /* A kind of type specifier. Note that this information is currently |
135 only used to distinguish tag definitions, tag references and typeof | 134 only used to distinguish tag definitions, tag references and typeof |
136 uses. */ | 135 uses. */ |
137 enum c_typespec_kind { | 136 enum c_typespec_kind { |
137 /* No typespec. This appears only in struct c_declspec. */ | |
138 ctsk_none, | |
138 /* A reserved keyword type specifier. */ | 139 /* A reserved keyword type specifier. */ |
139 ctsk_resword, | 140 ctsk_resword, |
140 /* A reference to a tag, previously declared, such as "struct foo". | 141 /* A reference to a tag, previously declared, such as "struct foo". |
141 This includes where the previous declaration was as a different | 142 This includes where the previous declaration was as a different |
142 kind of tag, in which case this is only valid if shadowing that | 143 kind of tag, in which case this is only valid if shadowing that |
158 /* A type specifier: this structure is created in the parser and | 159 /* A type specifier: this structure is created in the parser and |
159 passed to declspecs_add_type only. */ | 160 passed to declspecs_add_type only. */ |
160 struct c_typespec { | 161 struct c_typespec { |
161 /* What kind of type specifier this is. */ | 162 /* What kind of type specifier this is. */ |
162 enum c_typespec_kind kind; | 163 enum c_typespec_kind kind; |
164 /* Whether the expression has operands suitable for use in constant | |
165 expressions. */ | |
166 bool expr_const_operands; | |
163 /* The specifier itself. */ | 167 /* The specifier itself. */ |
164 tree spec; | 168 tree spec; |
165 /* An expression to be evaluated before the type specifier, in the | 169 /* An expression to be evaluated before the type specifier, in the |
166 case of typeof specifiers, or NULL otherwise or if no such | 170 case of typeof specifiers, or NULL otherwise or if no such |
167 expression is required for a particular typeof specifier. In | 171 expression is required for a particular typeof specifier. In |
169 modified type, that expression must be evaluated in order to | 173 modified type, that expression must be evaluated in order to |
170 determine array sizes that form part of the type, but the | 174 determine array sizes that form part of the type, but the |
171 expression itself (as opposed to the array sizes) forms no part | 175 expression itself (as opposed to the array sizes) forms no part |
172 of the type and so needs to be recorded separately. */ | 176 of the type and so needs to be recorded separately. */ |
173 tree expr; | 177 tree expr; |
174 /* Whether the expression has operands suitable for use in constant | |
175 expressions. */ | |
176 bool expr_const_operands; | |
177 }; | 178 }; |
178 | 179 |
179 /* A storage class specifier. */ | 180 /* A storage class specifier. */ |
180 enum c_storage_class { | 181 enum c_storage_class { |
181 csc_none, | 182 csc_none, |
194 cts_void, | 195 cts_void, |
195 cts_bool, | 196 cts_bool, |
196 cts_char, | 197 cts_char, |
197 cts_int, | 198 cts_int, |
198 cts_float, | 199 cts_float, |
200 cts_int128, | |
199 cts_double, | 201 cts_double, |
200 #ifndef noCbC | 202 #ifndef noCbC |
201 cts_CbC_code, | 203 cts_CbC_code, |
202 #endif | 204 #endif |
203 cts_dfloat32, | 205 cts_dfloat32, |
221 tree decl_attr; | 223 tree decl_attr; |
222 /* When parsing, the attributes. Outside the parser, this will be | 224 /* When parsing, the attributes. Outside the parser, this will be |
223 NULL; attributes (possibly from multiple lists) will be passed | 225 NULL; attributes (possibly from multiple lists) will be passed |
224 separately. */ | 226 separately. */ |
225 tree attrs; | 227 tree attrs; |
228 /* The storage class specifier, or csc_none if none. */ | |
229 enum c_storage_class storage_class; | |
226 /* Any type specifier keyword used such as "int", not reflecting | 230 /* Any type specifier keyword used such as "int", not reflecting |
227 modifiers such as "short", or cts_none if none. */ | 231 modifiers such as "short", or cts_none if none. */ |
228 enum c_typespec_keyword typespec_word; | 232 ENUM_BITFIELD (c_typespec_keyword) typespec_word : 8; |
229 /* The storage class specifier, or csc_none if none. */ | 233 /* The kind of type specifier if one has been seen, ctsk_none |
230 enum c_storage_class storage_class; | 234 otherwise. */ |
235 ENUM_BITFIELD (c_typespec_kind) typespec_kind : 3; | |
231 /* Whether any expressions in typeof specifiers may appear in | 236 /* Whether any expressions in typeof specifiers may appear in |
232 constant expressions. */ | 237 constant expressions. */ |
233 BOOL_BITFIELD expr_const_operands : 1; | 238 BOOL_BITFIELD expr_const_operands : 1; |
234 /* Whether any declaration specifiers have been seen at all. */ | 239 /* Whether any declaration specifiers have been seen at all. */ |
235 BOOL_BITFIELD declspecs_seen_p : 1; | 240 BOOL_BITFIELD declspecs_seen_p : 1; |
236 /* Whether a type specifier has been seen. */ | |
237 BOOL_BITFIELD type_seen_p : 1; | |
238 /* Whether something other than a storage class specifier or | 241 /* Whether something other than a storage class specifier or |
239 attribute has been seen. This is used to warn for the | 242 attribute has been seen. This is used to warn for the |
240 obsolescent usage of storage class specifiers other than at the | 243 obsolescent usage of storage class specifiers other than at the |
241 start of the list. (Doing this properly would require function | 244 start of the list. (Doing this properly would require function |
242 specifiers to be handled separately from storage class | 245 specifiers to be handled separately from storage class |
243 specifiers.) */ | 246 specifiers.) */ |
244 BOOL_BITFIELD non_sc_seen_p : 1; | 247 BOOL_BITFIELD non_sc_seen_p : 1; |
245 /* Whether the type is specified by a typedef or typeof name. */ | 248 /* Whether the type is specified by a typedef or typeof name. */ |
246 BOOL_BITFIELD typedef_p : 1; | 249 BOOL_BITFIELD typedef_p : 1; |
247 /* Whether a struct, union or enum type either had its content | |
248 defined by a type specifier in the list or was the first visible | |
249 declaration of its tag. */ | |
250 BOOL_BITFIELD tag_defined_p : 1; | |
251 /* Whether the type is explicitly "signed" or specified by a typedef | 250 /* Whether the type is explicitly "signed" or specified by a typedef |
252 whose type is explicitly "signed". */ | 251 whose type is explicitly "signed". */ |
253 BOOL_BITFIELD explicit_signed_p : 1; | 252 BOOL_BITFIELD explicit_signed_p : 1; |
254 /* Whether the specifiers include a deprecated typedef. */ | 253 /* Whether the specifiers include a deprecated typedef. */ |
255 BOOL_BITFIELD deprecated_p : 1; | 254 BOOL_BITFIELD deprecated_p : 1; |
256 /* Whether the type defaulted to "int" because there were no type | 255 /* Whether the type defaulted to "int" because there were no type |
257 specifiers. */ | 256 specifiers. */ |
258 BOOL_BITFIELD default_int_p; | 257 BOOL_BITFIELD default_int_p : 1; |
259 /* Whether "long" was specified. */ | 258 /* Whether "long" was specified. */ |
260 BOOL_BITFIELD long_p : 1; | 259 BOOL_BITFIELD long_p : 1; |
261 /* Whether "long" was specified more than once. */ | 260 /* Whether "long" was specified more than once. */ |
262 BOOL_BITFIELD long_long_p : 1; | 261 BOOL_BITFIELD long_long_p : 1; |
263 /* Whether "short" was specified. */ | 262 /* Whether "short" was specified. */ |
296 cdk_pointer, | 295 cdk_pointer, |
297 /* Parenthesized declarator with nested attributes. */ | 296 /* Parenthesized declarator with nested attributes. */ |
298 cdk_attrs | 297 cdk_attrs |
299 }; | 298 }; |
300 | 299 |
300 typedef struct c_arg_tag_d { | |
301 /* The argument name. */ | |
302 tree id; | |
303 /* The type of the argument. */ | |
304 tree type; | |
305 } c_arg_tag; | |
306 | |
307 DEF_VEC_O(c_arg_tag); | |
308 DEF_VEC_ALLOC_O(c_arg_tag,gc); | |
309 | |
301 /* Information about the parameters in a function declarator. */ | 310 /* Information about the parameters in a function declarator. */ |
302 struct c_arg_info { | 311 struct c_arg_info { |
303 /* A list of parameter decls. */ | 312 /* A list of parameter decls. */ |
304 tree parms; | 313 tree parms; |
305 /* A list of structure, union and enum tags defined. */ | 314 /* A list of structure, union and enum tags defined. */ |
306 tree tags; | 315 VEC(c_arg_tag,gc) *tags; |
307 /* A list of argument types to go in the FUNCTION_TYPE. */ | 316 /* A list of argument types to go in the FUNCTION_TYPE. */ |
308 tree types; | 317 tree types; |
309 /* A list of non-parameter decls (notably enumeration constants) | 318 /* A list of non-parameter decls (notably enumeration constants) |
310 defined with the parameters. */ | 319 defined with the parameters. */ |
311 tree others; | 320 tree others; |
312 /* A list of VLA sizes from the parameters. In a function | 321 /* A VEC of VLA sizes from the parameters. In a function |
313 definition, these are used to ensure that side-effects in sizes | 322 definition, these are used to ensure that side-effects in sizes |
314 of arrays converted to pointers (such as a parameter int i[n++]) | 323 of arrays converted to pointers (such as a parameter int i[n++]) |
315 take place; otherwise, they are ignored. */ | 324 take place; otherwise, they are ignored. */ |
316 tree pending_sizes; | 325 VEC(tree,gc) *pending_sizes; |
317 /* True when these arguments had [*]. */ | 326 /* True when these arguments had [*]. */ |
318 BOOL_BITFIELD had_vla_unspec : 1; | 327 BOOL_BITFIELD had_vla_unspec : 1; |
319 }; | 328 }; |
320 | 329 |
321 /* A declarator. */ | 330 /* A declarator. */ |
322 struct c_declarator { | 331 struct c_declarator { |
323 /* The kind of declarator. */ | 332 /* The kind of declarator. */ |
324 enum c_declarator_kind kind; | 333 enum c_declarator_kind kind; |
334 location_t id_loc; /* Currently only set for cdk_id, cdk_array. */ | |
325 /* Except for cdk_id, the contained declarator. For cdk_id, NULL. */ | 335 /* Except for cdk_id, the contained declarator. For cdk_id, NULL. */ |
326 struct c_declarator *declarator; | 336 struct c_declarator *declarator; |
327 location_t id_loc; /* Currently only set for cdk_id, cdk_array. */ | |
328 union { | 337 union { |
329 /* For identifiers, an IDENTIFIER_NODE or NULL_TREE if an abstract | 338 /* For identifiers, an IDENTIFIER_NODE or NULL_TREE if an abstract |
330 declarator. */ | 339 declarator. */ |
331 tree id; | 340 tree id; |
332 /* For functions. */ | 341 /* For functions. */ |
416 enum c_inline_static_type); | 425 enum c_inline_static_type); |
417 extern void c_init_decl_processing (void); | 426 extern void c_init_decl_processing (void); |
418 extern void c_print_identifier (FILE *, tree, int); | 427 extern void c_print_identifier (FILE *, tree, int); |
419 extern int quals_from_declspecs (const struct c_declspecs *); | 428 extern int quals_from_declspecs (const struct c_declspecs *); |
420 extern struct c_declarator *build_array_declarator (location_t, tree, | 429 extern struct c_declarator *build_array_declarator (location_t, tree, |
421 struct c_declspecs *, | 430 struct c_declspecs *, |
422 bool, bool); | 431 bool, bool); |
423 extern tree build_enumerator (location_t, struct c_enum_contents *, tree, tree); | 432 extern tree build_enumerator (location_t, location_t, struct c_enum_contents *, |
424 extern tree check_for_loop_decls (location_t); | 433 tree, tree); |
434 extern tree check_for_loop_decls (location_t, bool); | |
425 extern void mark_forward_parm_decls (void); | 435 extern void mark_forward_parm_decls (void); |
426 extern void declare_parm_level (void); | 436 extern void declare_parm_level (void); |
427 extern void undeclared_variable (location_t, tree); | 437 extern void undeclared_variable (location_t, tree); |
428 extern tree lookup_label_for_goto (location_t, tree); | 438 extern tree lookup_label_for_goto (location_t, tree); |
429 extern tree declare_label (tree); | 439 extern tree declare_label (tree); |
434 location_t, location_t); | 444 location_t, location_t); |
435 extern void finish_decl (tree, location_t, tree, tree, tree); | 445 extern void finish_decl (tree, location_t, tree, tree, tree); |
436 extern tree finish_enum (tree, tree, tree); | 446 extern tree finish_enum (tree, tree, tree); |
437 extern void finish_function (void); | 447 extern void finish_function (void); |
438 extern tree finish_struct (location_t, tree, tree, tree, | 448 extern tree finish_struct (location_t, tree, tree, tree, |
439 struct c_struct_parse_info *); | 449 struct c_struct_parse_info *); |
450 extern struct c_arg_info *build_arg_info (void); | |
440 extern struct c_arg_info *get_parm_info (bool); | 451 extern struct c_arg_info *get_parm_info (bool); |
441 extern tree grokfield (location_t, struct c_declarator *, | 452 extern tree grokfield (location_t, struct c_declarator *, |
442 struct c_declspecs *, tree, tree *); | 453 struct c_declspecs *, tree, tree *); |
443 extern tree groktypename (struct c_type_name *, tree *, bool *); | 454 extern tree groktypename (struct c_type_name *, tree *, bool *); |
444 extern tree grokparm (const struct c_parm *); | 455 extern tree grokparm (const struct c_parm *); |
496 extern bool c_missing_noreturn_ok_p (tree); | 507 extern bool c_missing_noreturn_ok_p (tree); |
497 extern bool c_warn_unused_global_decl (const_tree); | 508 extern bool c_warn_unused_global_decl (const_tree); |
498 extern void c_initialize_diagnostics (diagnostic_context *); | 509 extern void c_initialize_diagnostics (diagnostic_context *); |
499 extern bool c_vla_unspec_p (tree x, tree fn); | 510 extern bool c_vla_unspec_p (tree x, tree fn); |
500 | 511 |
501 #define c_build_type_variant(TYPE, CONST_P, VOLATILE_P) \ | |
502 c_build_qualified_type ((TYPE), \ | |
503 ((CONST_P) ? TYPE_QUAL_CONST : 0) | \ | |
504 ((VOLATILE_P) ? TYPE_QUAL_VOLATILE : 0)) | |
505 | |
506 /* in c-typeck.c */ | 512 /* in c-typeck.c */ |
507 extern bool in_late_binary_op; | |
508 extern int in_alignof; | 513 extern int in_alignof; |
509 extern int in_sizeof; | 514 extern int in_sizeof; |
510 extern int in_typeof; | 515 extern int in_typeof; |
511 | 516 |
512 extern struct c_switch *c_switch_stack; | 517 extern struct c_switch *c_switch_stack; |
513 | 518 |
514 extern tree c_objc_common_truthvalue_conversion (location_t, tree); | 519 extern tree c_objc_common_truthvalue_conversion (location_t, tree); |
515 extern tree require_complete_type (tree); | 520 extern tree require_complete_type (tree); |
516 extern int same_translation_unit_p (const_tree, const_tree); | 521 extern int same_translation_unit_p (const_tree, const_tree); |
517 extern int comptypes (tree, tree); | 522 extern int comptypes (tree, tree); |
523 extern int comptypes_check_different_types (tree, tree, bool *); | |
518 extern bool c_vla_type_p (const_tree); | 524 extern bool c_vla_type_p (const_tree); |
519 extern bool c_mark_addressable (tree); | 525 extern bool c_mark_addressable (tree); |
520 extern void c_incomplete_type_error (const_tree, const_tree); | 526 extern void c_incomplete_type_error (const_tree, const_tree); |
521 extern tree c_type_promotes_to (tree); | 527 extern tree c_type_promotes_to (tree); |
522 extern struct c_expr default_function_array_conversion (location_t, | 528 extern struct c_expr default_function_array_conversion (location_t, |
523 struct c_expr); | 529 struct c_expr); |
530 extern struct c_expr default_function_array_read_conversion (location_t, | |
531 struct c_expr); | |
532 extern void mark_exp_read (tree); | |
524 extern tree composite_type (tree, tree); | 533 extern tree composite_type (tree, tree); |
525 extern tree build_component_ref (location_t, tree, tree); | 534 extern tree build_component_ref (location_t, tree, tree); |
526 extern tree build_array_ref (location_t, tree, tree); | 535 extern tree build_array_ref (location_t, tree, tree); |
527 extern tree build_external_ref (location_t, tree, int, tree *); | 536 extern tree build_external_ref (location_t, tree, int, tree *); |
528 extern void pop_maybe_used (bool); | 537 extern void pop_maybe_used (bool); |
543 extern void pedwarn_init (location_t, int opt, const char *); | 552 extern void pedwarn_init (location_t, int opt, const char *); |
544 extern void maybe_warn_string_init (tree, struct c_expr); | 553 extern void maybe_warn_string_init (tree, struct c_expr); |
545 extern void start_init (tree, tree, int); | 554 extern void start_init (tree, tree, int); |
546 extern void finish_init (void); | 555 extern void finish_init (void); |
547 extern void really_start_incremental_init (tree); | 556 extern void really_start_incremental_init (tree); |
548 extern void push_init_level (int); | 557 extern void push_init_level (int, struct obstack *); |
549 extern struct c_expr pop_init_level (int); | 558 extern struct c_expr pop_init_level (int, struct obstack *); |
550 extern void set_init_index (tree, tree); | 559 extern void set_init_index (tree, tree, struct obstack *); |
551 extern void set_init_label (tree); | 560 extern void set_init_label (tree, struct obstack *); |
552 extern void process_init_element (struct c_expr, bool); | 561 extern void process_init_element (struct c_expr, bool, struct obstack *); |
553 extern tree build_compound_literal (location_t, tree, tree, bool); | 562 extern tree build_compound_literal (location_t, tree, tree, bool); |
554 extern void check_compound_literal_type (location_t, struct c_type_name *); | 563 extern void check_compound_literal_type (location_t, struct c_type_name *); |
555 extern tree c_start_case (location_t, location_t, tree); | 564 extern tree c_start_case (location_t, location_t, tree); |
556 extern void c_finish_case (tree); | 565 extern void c_finish_case (tree); |
557 extern tree build_asm_expr (location_t, tree, tree, tree, tree, tree, bool); | 566 extern tree build_asm_expr (location_t, tree, tree, tree, tree, tree, bool); |
603 | 612 |
604 /* In c-decl.c */ | 613 /* In c-decl.c */ |
605 extern void c_finish_incomplete_decl (tree); | 614 extern void c_finish_incomplete_decl (tree); |
606 extern void c_write_global_declarations (void); | 615 extern void c_write_global_declarations (void); |
607 | 616 |
608 /* In order for the format checking to accept the C frontend | 617 /* In c-errors.c */ |
609 diagnostic framework extensions, you must include this file before | 618 extern void pedwarn_c90 (location_t, int opt, const char *, ...) ATTRIBUTE_GCC_DIAG(3,4); |
610 toplev.h, not after. */ | 619 extern void pedwarn_c99 (location_t, int opt, const char *, ...) ATTRIBUTE_GCC_DIAG(3,4); |
611 #if GCC_VERSION >= 4001 | |
612 #define ATTRIBUTE_GCC_CDIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m ,n))) ATTRIBUTE_NONNULL(m) | |
613 #else | |
614 #define ATTRIBUTE_GCC_CDIAG(m, n) ATTRIBUTE_NONNULL(m) | |
615 #endif | |
616 | |
617 extern void pedwarn_c90 (location_t, int opt, const char *, ...) ATTRIBUTE_GCC_CDIAG(3,4); | |
618 extern void pedwarn_c99 (location_t, int opt, const char *, ...) ATTRIBUTE_GCC_CDIAG(3,4); | |
619 | |
620 extern bool c_cpp_error (cpp_reader *, int, location_t, unsigned int, | |
621 const char *, va_list *) | |
622 ATTRIBUTE_GCC_CDIAG(5,0); | |
623 | 620 |
624 #endif /* ! GCC_C_TREE_H */ | 621 #endif /* ! GCC_C_TREE_H */ |