| /* Process declarations and variables for C compiler. |
| Copyright (C) 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, |
| 2001, 2002, 2003, 2004 Free Software Foundation, Inc. |
| |
| This file is part of GCC. |
| |
| GCC is free software; you can redistribute it and/or modify it under |
| the terms of the GNU General Public License as published by the Free |
| Software Foundation; either version 2, or (at your option) any later |
| version. |
| |
| GCC is distributed in the hope that it will be useful, but WITHOUT ANY |
| WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| for more details. |
| |
| You should have received a copy of the GNU General Public License |
| along with GCC; see the file COPYING. If not, write to the Free |
| Software Foundation, 59 Temple Place - Suite 330, Boston, MA |
| 02111-1307, USA. */ |
| |
| /* Process declarations and symbol lookup for C front end. |
| Also constructs types; the standard scalar types at initialization, |
| and structure, union, array and enum types when they are declared. */ |
| |
| /* ??? not all decl nodes are given the most useful possible |
| line numbers. For example, the CONST_DECLs for enum values. */ |
| |
| #include "config.h" |
| #include "system.h" |
| #include "coretypes.h" |
| #include "tm.h" |
| #include "intl.h" |
| #include "tree.h" |
| #include "tree-inline.h" |
| #include "rtl.h" |
| #include "flags.h" |
| #include "function.h" |
| #include "output.h" |
| #include "expr.h" |
| #include "c-tree.h" |
| #include "toplev.h" |
| #include "ggc.h" |
| #include "tm_p.h" |
| #include "cpplib.h" |
| #include "target.h" |
| #include "debug.h" |
| #include "opts.h" |
| #include "timevar.h" |
| #include "c-common.h" |
| #include "c-pragma.h" |
| #include "cgraph.h" |
| #include "hashtab.h" |
| #include "libfuncs.h" |
| #include "except.h" |
| #include "langhooks-def.h" |
| |
| /* In grokdeclarator, distinguish syntactic contexts of declarators. */ |
| enum decl_context |
| { NORMAL, /* Ordinary declaration */ |
| FUNCDEF, /* Function definition */ |
| PARM, /* Declaration of parm before function body */ |
| FIELD, /* Declaration inside struct or union */ |
| TYPENAME}; /* Typename (inside cast or sizeof) */ |
| |
| |
| /* Nonzero if we have seen an invalid cross reference |
| to a struct, union, or enum, but not yet printed the message. */ |
| |
| tree pending_invalid_xref; |
| /* File and line to appear in the eventual error message. */ |
| location_t pending_invalid_xref_location; |
| |
| /* While defining an enum type, this is 1 plus the last enumerator |
| constant value. Note that will do not have to save this or `enum_overflow' |
| around nested function definition since such a definition could only |
| occur in an enum value expression and we don't use these variables in |
| that case. */ |
| |
| static tree enum_next_value; |
| |
| /* Nonzero means that there was overflow computing enum_next_value. */ |
| |
| static int enum_overflow; |
| |
| /* Parsing a function declarator leaves a list of parameter names |
| or a chain of parameter decls here. */ |
| |
| static tree last_function_parms; |
| |
| /* ... and a chain of structure and enum types declared in the |
| parmlist here. */ |
| |
| static tree last_function_parm_tags; |
| |
| /* ... and a chain of all non-parameter declarations (such as |
| CONST_DECLs from enumerations) here. */ |
| |
| static tree last_function_parm_others; |
| |
| /* After parsing the declarator that starts a function definition, |
| `start_function' puts the list of parameter names or chain of decls here |
| for `store_parm_decls' to find. */ |
| |
| static tree current_function_parms; |
| |
| /* Similar, for last_function_parm_tags. */ |
| |
| static tree current_function_parm_tags; |
| |
| /* And for last_function_parm_others. */ |
| |
| static tree current_function_parm_others; |
| |
| /* Similar, for the file and line that the prototype came from if this is |
| an old-style definition. */ |
| |
| static location_t current_function_prototype_locus; |
| |
| /* The current statement tree. */ |
| |
| static GTY(()) struct stmt_tree_s c_stmt_tree; |
| |
| /* The current scope statement stack. */ |
| |
| static GTY(()) tree c_scope_stmt_stack; |
| |
| /* State saving variables. */ |
| int c_in_iteration_stmt; |
| int c_in_case_stmt; |
| |
| /* A list of external DECLs that appeared at block scope when there was |
| some other global meaning for that identifier. */ |
| static GTY(()) tree truly_local_externals; |
| |
| /* All the builtins; this is a subset of the entries of global_scope. */ |
| |
| static GTY(()) tree first_builtin_decl; |
| static GTY(()) tree last_builtin_decl; |
| |
| /* A DECL for the current file-scope context. */ |
| |
| static GTY(()) tree current_file_decl; |
| |
| /* Set to 0 at beginning of a function definition, set to 1 if |
| a return statement that specifies a return value is seen. */ |
| |
| int current_function_returns_value; |
| |
| /* Set to 0 at beginning of a function definition, set to 1 if |
| a return statement with no argument is seen. */ |
| |
| int current_function_returns_null; |
| |
| /* Set to 0 at beginning of a function definition, set to 1 if |
| a call to a noreturn function is seen. */ |
| |
| int current_function_returns_abnormally; |
| |
| /* Set to nonzero by `grokdeclarator' for a function |
| whose return type is defaulted, if warnings for this are desired. */ |
| |
| static int warn_about_return_type; |
| |
| /* Nonzero when starting a function declared `extern inline'. */ |
| |
| static int current_extern_inline; |
| |
| /* Each c_scope structure describes the complete contents of one scope. |
| Three scopes are distinguished specially: the innermost or current |
| scope, the innermost function scope, and the outermost or file scope. |
| |
| Most declarations are recorded in the current scope. |
| |
| All normal label declarations are recorded in the innermost |
| function scope, as are bindings of undeclared identifiers to |
| error_mark_node. (GCC permits nested functions as an extension, |
| hence the 'innermost' qualifier.) Explicitly declared labels |
| (using the __label__ extension) appear in the current scope. |
| |
| Being in the global scope (current_scope == global_scope) causes |
| special behavior in several places below. Also, under some |
| conditions the Objective-C front end records declarations in the |
| global scope even though that isn't the current scope. |
| |
| The order of the names, parms, and blocks lists matters, and they |
| are frequently appended to. To avoid having to walk all the way to |
| the end of the list on each insertion, or reverse the lists later, |
| we maintain a pointer to the last list entry for each of the lists. |
| |
| The order of the tags, shadowed, and shadowed_tags |
| lists does not matter, so we just prepend to these lists. */ |
| |
| struct c_scope GTY(()) |
| { |
| /* The scope containing this one. */ |
| struct c_scope *outer; |
| |
| /* The next outermost function scope. */ |
| struct c_scope *outer_function; |
| |
| /* All variables, constants, functions, labels, and typedef names. */ |
| tree names; |
| tree names_last; |
| |
| /* All parameter declarations. Used only in the outermost scope of |
| a function. */ |
| tree parms; |
| tree parms_last; |
| |
| /* All structure, union, and enum type tags. */ |
| tree tags; |
| |
| /* For each scope, a list of shadowed outer-scope definitions |
| to be restored when this scope is popped. |
| Each link is a TREE_LIST whose TREE_PURPOSE is an identifier and |
| whose TREE_VALUE is its old definition (a kind of ..._DECL node). */ |
| tree shadowed; |
| |
| /* For each scope, a list of shadowed outer-scope tag definitions |
| to be restored when this scope is popped. |
| Each link is a TREE_LIST whose TREE_PURPOSE is an identifier and |
| whose TREE_VALUE is its old definition (a kind of ..._TYPE node). */ |
| tree shadowed_tags; |
| |
| /* For each scope (except the global one), a chain of BLOCK nodes |
| for all the scopes that were entered and exited one level down. */ |
| tree blocks; |
| tree blocks_last; |
| |
| /* True if we are currently filling this scope with parameter |
| declarations. */ |
| BOOL_BITFIELD parm_flag : 1; |
| |
| /* True if we already complained about forward parameter decls |
| in this scope. This prevents double warnings on |
| foo (int a; int b; ...) */ |
| BOOL_BITFIELD warned_forward_parm_decls : 1; |
| |
| /* True if this is the outermost block scope of a function body. |
| This scope contains the parameters, the local variables declared |
| in the outermost block, and all the labels (except those in |
| nested functions, or declared at block scope with __label__). */ |
| BOOL_BITFIELD function_body : 1; |
| |
| /* True means make a BLOCK for this scope no matter what. */ |
| BOOL_BITFIELD keep : 1; |
| }; |
| |
| /* The scope currently in effect. */ |
| |
| static GTY(()) struct c_scope *current_scope; |
| |
| /* A chain of c_scope structures awaiting reuse. */ |
| |
| static GTY((deletable (""))) struct c_scope *scope_freelist; |
| |
| /* The innermost function scope. Ordinary (not explicitly declared) |
| labels, bindings to error_mark_node, and the lazily-created |
| bindings of __func__ and its friends get this scope. */ |
| |
| static GTY(()) struct c_scope *current_function_scope; |
| |
| /* The outermost scope, corresponding to the C "file scope". This is |
| created when the compiler is started and exists through the entire run. */ |
| |
| static GTY(()) struct c_scope *global_scope; |
| |
| /* Append VAR to LIST in scope SCOPE. */ |
| #define SCOPE_LIST_APPEND(scope, list, decl) do { \ |
| struct c_scope *s_ = (scope); \ |
| tree d_ = (decl); \ |
| if (s_->list##_last) \ |
| TREE_CHAIN (s_->list##_last) = d_; \ |
| else \ |
| s_->list = d_; \ |
| s_->list##_last = d_; \ |
| } while (0) |
| |
| /* Concatenate FROM in scope FSCOPE onto TO in scope TSCOPE. */ |
| #define SCOPE_LIST_CONCAT(tscope, to, fscope, from) do { \ |
| struct c_scope *t_ = (tscope); \ |
| struct c_scope *f_ = (fscope); \ |
| if (t_->to##_last) \ |
| TREE_CHAIN (t_->to##_last) = f_->from; \ |
| else \ |
| t_->to = f_->from; \ |
| t_->to##_last = f_->from##_last; \ |
| } while (0) |
| |
| /* True means unconditionally make a BLOCK for the next scope pushed. */ |
| |
| static bool keep_next_level_flag; |
| |
| /* True means the next call to pushlevel will be the outermost scope |
| of a function body, so do not push a new scope, merely cease |
| expecting parameter decls. */ |
| |
| static bool next_is_function_body; |
| |
| /* Functions called automatically at the beginning and end of execution. */ |
| |
| tree static_ctors, static_dtors; |
| |
| /* Forward declarations. */ |
| |
| static struct c_scope *make_scope (void); |
| static void pop_scope (void); |
| static tree make_label (tree, location_t); |
| static void bind_label (tree, tree, struct c_scope *); |
| static void implicit_decl_warning (tree); |
| static tree lookup_tag (enum tree_code, tree, int); |
| static tree lookup_name_current_level (tree); |
| static tree grokdeclarator (tree, tree, enum decl_context, int, tree *); |
| static tree grokparms (tree, int); |
| static void layout_array_type (tree); |
| static void store_parm_decls_newstyle (void); |
| static void store_parm_decls_oldstyle (void); |
| static tree c_make_fname_decl (tree, int); |
| static void c_expand_body_1 (tree, int); |
| static tree any_external_decl (tree); |
| static void record_external_decl (tree); |
| static void warn_if_shadowing (tree, tree); |
| static void check_bitfield_type_and_width (tree *, tree *, const char *); |
| static void clone_underlying_type (tree); |
| static bool flexible_array_type_p (tree); |
| static hashval_t link_hash_hash (const void *); |
| static int link_hash_eq (const void *, const void *); |
| |
| /* States indicating how grokdeclarator() should handle declspecs marked |
| with __attribute__((deprecated)). An object declared as |
| __attribute__((deprecated)) suppresses warnings of uses of other |
| deprecated items. */ |
| |
| enum deprecated_states { |
| DEPRECATED_NORMAL, |
| DEPRECATED_SUPPRESS |
| }; |
| |
| static enum deprecated_states deprecated_state = DEPRECATED_NORMAL; |
| |
| void |
| c_print_identifier (FILE *file, tree node, int indent) |
| { |
| print_node (file, "symbol", IDENTIFIER_SYMBOL_VALUE (node), indent + 4); |
| print_node (file, "tag", IDENTIFIER_TAG_VALUE (node), indent + 4); |
| print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4); |
| if (C_IS_RESERVED_WORD (node)) |
| { |
| tree rid = ridpointers[C_RID_CODE (node)]; |
| indent_to (file, indent + 4); |
| fprintf (file, "rid " HOST_PTR_PRINTF " \"%s\"", |
| (void *) rid, IDENTIFIER_POINTER (rid)); |
| } |
| } |
| |
| /* Hook called at end of compilation to assume 1 elt |
| for a file-scope tentative array defn that wasn't complete before. */ |
| |
| void |
| c_finish_incomplete_decl (tree decl) |
| { |
| if (TREE_CODE (decl) == VAR_DECL) |
| { |
| tree type = TREE_TYPE (decl); |
| if (type != error_mark_node |
| && TREE_CODE (type) == ARRAY_TYPE |
| && ! DECL_EXTERNAL (decl) |
| && TYPE_DOMAIN (type) == 0) |
| { |
| warning ("%Jarray '%D' assumed to have one element", decl, decl); |
| |
| complete_array_type (type, NULL_TREE, 1); |
| |
| layout_decl (decl, 0); |
| } |
| } |
| } |
| |
| /* Reuse or create a struct for this scope. */ |
| |
| static struct c_scope * |
| make_scope (void) |
| { |
| struct c_scope *result; |
| if (scope_freelist) |
| { |
| result = scope_freelist; |
| scope_freelist = result->outer; |
| } |
| else |
| result = ggc_alloc_cleared (sizeof (struct c_scope)); |
| |
| return result; |
| } |
| |
| /* Remove the topmost scope from the stack and add it to the |
| free list, updating current_function_scope if necessary. */ |
| |
| static void |
| pop_scope (void) |
| { |
| struct c_scope *scope = current_scope; |
| |
| current_scope = scope->outer; |
| if (scope->function_body) |
| current_function_scope = scope->outer_function; |
| |
| memset (scope, 0, sizeof (struct c_scope)); |
| scope->outer = scope_freelist; |
| scope_freelist = scope; |
| } |
| |
| /* The Objective-C front-end often needs to determine the current scope. */ |
| |
| void * |
| get_current_scope (void) |
| { |
| return current_scope; |
| } |
| |
| /* The following function is used only by Objective-C. It needs to live here |
| because it accesses the innards of c_scope. */ |
| |
| void |
| objc_mark_locals_volatile (void *enclosing_blk) |
| { |
| struct c_scope *scope; |
| |
| for (scope = current_scope; |
| scope && scope != enclosing_blk; |
| scope = scope->outer) |
| { |
| tree decl; |
| |
| for (decl = scope->names; decl; decl = TREE_CHAIN (decl)) |
| { |
| DECL_REGISTER (decl) = 0; |
| TREE_THIS_VOLATILE (decl) = 1; |
| } |
| /* Do not climb up past the current function. */ |
| if (scope->function_body) |
| break; |
| } |
| } |
| |
| /* Nonzero if we are currently in the global scope. */ |
| |
| int |
| global_bindings_p (void) |
| { |
| return current_scope == global_scope; |
| } |
| |
| void |
| keep_next_level (void) |
| { |
| keep_next_level_flag = true; |
| } |
| |
| /* Identify this scope as currently being filled with parameters. */ |
| |
| void |
| declare_parm_level (void) |
| { |
| current_scope->parm_flag = true; |
| } |
| |
| /* Nonzero if currently making parm declarations. */ |
| |
| int |
| in_parm_level_p (void) |
| { |
| return current_scope->parm_flag; |
| } |
| |
| /* Enter a new scope. The dummy parameter is for signature |
| compatibility with lang_hooks.decls.pushlevel. */ |
| |
| void |
| pushlevel (int dummy ATTRIBUTE_UNUSED) |
| { |
| if (next_is_function_body) |
| { |
| /* This is the transition from the parameters to the top level |
| of the function body. These are the same scope |
| (C99 6.2.1p4,6) so we do not push another scope structure. |
| next_is_function_body is set only by store_parm_decls, which |
| in turn is called when and only when we are about to |
| encounter the opening curly brace for the function body. |
| |
| The outermost block of a function always gets a BLOCK node, |
| because the debugging output routines expect that each |
| function has at least one BLOCK. */ |
| current_scope->parm_flag = false; |
| current_scope->function_body = true; |
| current_scope->keep = true; |
| current_scope->outer_function = current_function_scope; |
| current_function_scope = current_scope; |
| |
| keep_next_level_flag = false; |
| next_is_function_body = false; |
| } |
| else |
| { |
| struct c_scope *scope = make_scope (); |
| |
| scope->keep = keep_next_level_flag; |
| scope->outer = current_scope; |
| current_scope = scope; |
| keep_next_level_flag = false; |
| } |
| } |
| |
| /* Exit a scope. Restore the state of the identifier-decl mappings |
| that were in effect when this scope was entered. |
| |
| If KEEP is KEEP_YES (1), this scope had explicit declarations, so |
| create a BLOCK node to record its declarations and subblocks for |
| debugging output. If KEEP is KEEP_MAYBE, do so only if the names |
| or tags lists are nonempty. |
| |
| The second parameter is ignored; it is present only for |
| signature compatibility with lang_hooks.decls.poplevel. |
| |
| If FUNCTIONBODY is nonzero, this level is the body of a function, |
| even if current_scope->function_body is not set. This is used |
| by language-independent code that generates synthetic functions, |
| and cannot set current_scope->function_body. |
| |
| FIXME: Eliminate the need for all arguments. */ |
| |
| tree |
| poplevel (int keep, int dummy ATTRIBUTE_UNUSED, int functionbody) |
| { |
| struct c_scope *scope = current_scope; |
| tree block; |
| tree decl; |
| tree p; |
| |
| /* The following line does not use |= due to a bug in HP's C compiler. */ |
| scope->function_body = scope->function_body | functionbody; |
| |
| if (keep == KEEP_MAYBE) |
| keep = (scope->names || scope->tags); |
| |
| keep |= scope->keep; |
| keep |= scope->function_body; |
| |
| /* If appropriate, create a BLOCK to record the decls for the life |
| of this function. */ |
| block = 0; |
| if (keep) |
| { |
| block = make_node (BLOCK); |
| BLOCK_VARS (block) = scope->names; |
| BLOCK_SUBBLOCKS (block) = scope->blocks; |
| TREE_USED (block) = 1; |
| } |
| |
| /* In each subblock, record that this is its superior. */ |
| for (p = scope->blocks; p; p = TREE_CHAIN (p)) |
| BLOCK_SUPERCONTEXT (p) = block; |
| |
| /* Clear out the variable bindings in this scope. |
| |
| Propagate TREE_ADDRESSABLE from nested functions to their |
| containing functions. |
| |
| Issue warnings for unused variables and labels, and errors for |
| undefined labels, if there are any. */ |
| |
| for (p = scope->names; p; p = TREE_CHAIN (p)) |
| { |
| switch (TREE_CODE (p)) |
| { |
| case LABEL_DECL: |
| if (TREE_USED (p) && !DECL_INITIAL (p)) |
| { |
| error ("%Jlabel `%D' used but not defined", p, p); |
| DECL_INITIAL (p) = error_mark_node; |
| } |
| else if (!TREE_USED (p) && warn_unused_label) |
| { |
| if (DECL_INITIAL (p)) |
| warning ("%Jlabel `%D' defined but not used", p, p); |
| else |
| warning ("%Jlabel `%D' declared but not defined", p, p); |
| } |
| |
| IDENTIFIER_LABEL_VALUE (DECL_NAME (p)) = 0; |
| break; |
| |
| case FUNCTION_DECL: |
| if (! TREE_ASM_WRITTEN (p) |
| && DECL_INITIAL (p) != 0 |
| && TREE_ADDRESSABLE (p) |
| && DECL_ABSTRACT_ORIGIN (p) != 0 |
| && DECL_ABSTRACT_ORIGIN (p) != p) |
| TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (p)) = 1; |
| goto normal; |
| |
| case VAR_DECL: |
| /* Keep this in sync with stmt.c:warn_about_unused_variables. |
| No warnings when the global scope is popped because the |
| global scope isn't popped for the last translation unit, |
| so the warnings are done in c_write_global_declaration. */ |
| if (warn_unused_variable && scope != global_scope |
| && !TREE_USED (p) |
| && !DECL_IN_SYSTEM_HEADER (p) |
| && DECL_NAME (p) |
| && !DECL_ARTIFICIAL (p)) |
| warning ("%Junused variable `%D'", p, p); |
| /* fall through */ |
| |
| default: |
| normal: |
| if (DECL_NAME (p)) |
| { |
| if (DECL_EXTERNAL (p) && scope != global_scope) |
| /* External decls stay in the symbol-value slot but are |
| inaccessible. */ |
| C_DECL_INVISIBLE (p) = 1; |
| else |
| IDENTIFIER_SYMBOL_VALUE (DECL_NAME (p)) = 0; |
| } |
| break; |
| } |
| } |
| |
| /* Clear out the parameter bindings in this scope, if any. |
| Unused-parameter warnings are handled by function.c. */ |
| for (p = scope->parms; p; p = TREE_CHAIN (p)) |
| if (DECL_NAME (p)) |
| IDENTIFIER_SYMBOL_VALUE (DECL_NAME (p)) = 0; |
| |
| /* Clear out the tag-meanings declared in this scope. |
| |
| Set the TYPE_CONTEXTs for all of the tagged types belonging to |
| this scope so that they point to the appropriate construct, i.e. |
| either to the current FUNCTION_DECL node, or else to the BLOCK |
| node we just constructed. |
| |
| Note that for tagged types whose scope is just the formal |
| parameter list for some function type specification, we can't |
| properly set their TYPE_CONTEXTs here, because we don't have a |
| pointer to the appropriate FUNCTION_TYPE node readily available |
| to us. For those cases, the TYPE_CONTEXTs of the relevant tagged |
| type nodes get set in `grokdeclarator' as soon as we have created |
| the FUNCTION_TYPE node which will represent the "scope" for these |
| "parameter list local" tagged types. */ |
| |
| decl = scope->function_body ? current_function_decl : block; |
| for (p = scope->tags; p; p = TREE_CHAIN (p)) |
| { |
| if (TREE_PURPOSE (p)) |
| IDENTIFIER_TAG_VALUE (TREE_PURPOSE (p)) = 0; |
| if (decl) |
| TYPE_CONTEXT (TREE_VALUE (p)) = decl; |
| } |
| |
| /* Restore all name- and label-meanings from outer scopes that were |
| shadowed by this scope. */ |
| for (p = scope->shadowed; p; p = TREE_CHAIN (p)) |
| if (TREE_VALUE (p) && TREE_CODE (TREE_VALUE (p)) == LABEL_DECL) |
| IDENTIFIER_LABEL_VALUE (TREE_PURPOSE (p)) = TREE_VALUE (p); |
| else |
| IDENTIFIER_SYMBOL_VALUE (TREE_PURPOSE (p)) = TREE_VALUE (p); |
| |
| /* Restore all tag-meanings from outer scopes that were shadowed by |
| this scope. */ |
| for (p = scope->shadowed_tags; p; p = TREE_CHAIN (p)) |
| IDENTIFIER_TAG_VALUE (TREE_PURPOSE (p)) = TREE_VALUE (p); |
| |
| /* Dispose of the block that we just made inside some higher level. */ |
| if (scope->function_body && current_function_decl) |
| DECL_INITIAL (current_function_decl) = block; |
| else if (scope->outer) |
| { |
| if (block) |
| SCOPE_LIST_APPEND (scope->outer, blocks, block); |
| /* If we did not make a block for the scope just exited, any |
| blocks made for inner scopes must be carried forward so they |
| will later become subblocks of something else. */ |
| else if (scope->blocks) |
| SCOPE_LIST_CONCAT (scope->outer, blocks, scope, blocks); |
| } |
| |
| /* Pop the current scope, and free the structure for reuse. */ |
| pop_scope (); |
| |
| return block; |
| } |
| |
| /* Insert BLOCK at the end of the list of subblocks of the current |
| scope. This is used when a BIND_EXPR is expanded, to handle the |
| BLOCK node inside the BIND_EXPR. */ |
| |
| void |
| insert_block (tree block) |
| { |
| TREE_USED (block) = 1; |
| SCOPE_LIST_APPEND (current_scope, blocks, block); |
| } |
| |
| /* Set the BLOCK node for the innermost scope (the one we are |
| currently in). The RTL expansion machinery requires us to provide |
| this hook, but it is not useful in function-at-a-time mode. */ |
| |
| void |
| set_block (tree block ATTRIBUTE_UNUSED) |
| { |
| } |
| |
| /* Push a definition or a declaration of struct, union or enum tag "name". |
| "type" should be the type node. |
| We assume that the tag "name" is not already defined. |
| |
| Note that the definition may really be just a forward reference. |
| In that case, the TYPE_SIZE will be zero. */ |
| |
| void |
| pushtag (tree name, tree type) |
| { |
| struct c_scope *b = current_scope; |
| |
| /* Record the identifier as the type's name if it has none. */ |
| if (name) |
| { |
| if (TYPE_NAME (type) == 0) |
| TYPE_NAME (type) = name; |
| |
| if (IDENTIFIER_TAG_VALUE (name)) |
| b->shadowed_tags = tree_cons (name, IDENTIFIER_TAG_VALUE (name), |
| b->shadowed_tags); |
| IDENTIFIER_TAG_VALUE (name) = type; |
| } |
| |
| b->tags = tree_cons (name, type, b->tags); |
| |
| /* Create a fake NULL-named TYPE_DECL node whose TREE_TYPE will be the |
| tagged type we just added to the current scope. This fake |
| NULL-named TYPE_DECL node helps dwarfout.c to know when it needs |
| to output a representation of a tagged type, and it also gives |
| us a convenient place to record the "scope start" address for the |
| tagged type. */ |
| |
| TYPE_STUB_DECL (type) = pushdecl (build_decl (TYPE_DECL, NULL_TREE, type)); |
| |
| /* An approximation for now, so we can tell this is a function-scope tag. |
| This will be updated in poplevel. */ |
| TYPE_CONTEXT (type) = DECL_CONTEXT (TYPE_STUB_DECL (type)); |
| } |
| |
| /* Subroutine of compare_decls. Allow harmless mismatches in return |
| and argument types provided that the type modes match. This function |
| return a unified type given a suitable match, and 0 otherwise. */ |
| |
| static tree |
| match_builtin_function_types (tree newtype, tree oldtype) |
| { |
| tree newrettype, oldrettype; |
| tree newargs, oldargs; |
| tree trytype, tryargs; |
| |
| /* Accept the return type of the new declaration if same modes. */ |
| oldrettype = TREE_TYPE (oldtype); |
| newrettype = TREE_TYPE (newtype); |
| |
| if (TYPE_MODE (oldrettype) != TYPE_MODE (newrettype)) |
| return 0; |
| |
| oldargs = TYPE_ARG_TYPES (oldtype); |
| newargs = TYPE_ARG_TYPES (newtype); |
| tryargs = newargs; |
| |
| while (oldargs || newargs) |
| { |
| if (! oldargs |
| || ! newargs |
| || ! TREE_VALUE (oldargs) |
| || ! TREE_VALUE (newargs) |
| || TYPE_MODE (TREE_VALUE (oldargs)) |
| != TYPE_MODE (TREE_VALUE (newargs))) |
| return 0; |
| |
| oldargs = TREE_CHAIN (oldargs); |
| newargs = TREE_CHAIN (newargs); |
| } |
| |
| trytype = build_function_type (newrettype, tryargs); |
| return build_type_attribute_variant (trytype, TYPE_ATTRIBUTES (oldtype)); |
| } |
| |
| /* Subroutine of diagnose_mismathed_decls. Check for function type |
| mismatch involving an empty arglist vs a nonempty one and give clearer |
| diagnostics. */ |
| static void |
| diagnose_arglist_conflict (tree newdecl, tree olddecl, |
| tree newtype, tree oldtype) |
| { |
| tree t; |
| |
| if (TREE_CODE (olddecl) != FUNCTION_DECL |
| || !comptypes (TREE_TYPE (oldtype), TREE_TYPE (newtype), COMPARE_STRICT) |
| || !((TYPE_ARG_TYPES (oldtype) == 0 && DECL_INITIAL (olddecl) == 0) |
| || |
| (TYPE_ARG_TYPES (newtype) == 0 && DECL_INITIAL (newdecl) == 0))) |
| return; |
| |
| t = TYPE_ARG_TYPES (oldtype); |
| if (t == 0) |
| t = TYPE_ARG_TYPES (newtype); |
| for (; t; t = TREE_CHAIN (t)) |
| { |
| tree type = TREE_VALUE (t); |
| |
| if (TREE_CHAIN (t) == 0 |
| && TYPE_MAIN_VARIANT (type) != void_type_node) |
| { |
| inform ("a parameter list with an ellipsis can't match " |
| "an empty parameter name list declaration"); |
| break; |
| } |
| |
| if (c_type_promotes_to (type) != type) |
| { |
| inform ("an argument type that has a default promotion can't match " |
| "an empty parameter name list declaration"); |
| break; |
| } |
| } |
| } |
| |
| /* Another subroutine of diagnose_mismatched_decls. OLDDECL is an |
| old-style function definition, NEWDECL is a prototype declaration. |
| Diagnose inconsistencies in the argument list. Returns TRUE if |
| the prototype is compatible, FALSE if not. */ |
| static bool |
| validate_proto_after_old_defn (tree newdecl, tree newtype, tree oldtype) |
| { |
| tree newargs, oldargs; |
| int i; |
| |
| /* ??? Elsewhere TYPE_MAIN_VARIANT is not used in this context. */ |
| #define END_OF_ARGLIST(t) (TYPE_MAIN_VARIANT (t) == void_type_node) |
| |
| oldargs = TYPE_ACTUAL_ARG_TYPES (oldtype); |
| newargs = TYPE_ARG_TYPES (newtype); |
| i = 1; |
| |
| for (;;) |
| { |
| tree oldargtype = TREE_VALUE (oldargs); |
| tree newargtype = TREE_VALUE (newargs); |
| |
| if (END_OF_ARGLIST (oldargtype) && END_OF_ARGLIST (newargtype)) |
| break; |
| |
| /* Reaching the end of just one list means the two decls don't |
| agree on the number of arguments. */ |
| if (END_OF_ARGLIST (oldargtype)) |
| { |
| error ("%Jprototype for '%D' declares more arguments " |
| "than previous old-style definition", newdecl, newdecl); |
| return false; |
| } |
| else if (END_OF_ARGLIST (newargtype)) |
| { |
| error ("%Jprototype for '%D' declares fewer arguments " |
| "than previous old-style definition", newdecl, newdecl); |
| return false; |
| } |
| |
| /* Type for passing arg must be consistent with that declared |
| for the arg. */ |
| else if (! comptypes (oldargtype, newargtype, COMPARE_STRICT)) |
| { |
| error ("%Jprototype for '%D' declares arg %d with incompatible type", |
| newdecl, newdecl, i); |
| return false; |
| } |
| |
| oldargs = TREE_CHAIN (oldargs); |
| newargs = TREE_CHAIN (newargs); |
| i++; |
| } |
| |
| /* If we get here, no errors were found, but do issue a warning |
| for this poor-style construct. */ |
| warning ("%Jprototype for '%D' follows non-prototype definition", |
| newdecl, newdecl); |
| return true; |
| #undef END_OF_ARGLIST |
| } |
| |
| /* Subroutine of diagnose_mismatched_decls. Report the location of DECL, |
| first in a pair of mismatched declarations, using the diagnostic |
| function DIAG. */ |
| static void |
| locate_old_decl (tree decl, void (*diag)(const char *, ...)) |
| { |
| if (TREE_CODE (decl) == FUNCTION_DECL && DECL_BUILT_IN (decl)) |
| ; |
| else if (DECL_INITIAL (decl)) |
| diag (N_("%Jprevious definition of '%D' was here"), decl, decl); |
| else if (C_DECL_IMPLICIT (decl)) |
| diag (N_("%Jprevious implicit declaration of '%D' was here"), decl, decl); |
| else |
| diag (N_("%Jprevious declaration of '%D' was here"), decl, decl); |
| } |
| |
| /* Subroutine of duplicate_decls. Compare NEWDECL to OLDDECL. |
| Returns true if the caller should proceed to merge the two, false |
| if OLDDECL should simply be discarded. As a side effect, issues |
| all necessary diagnostics for invalid or poor-style combinations. |
| If it returns true, writes the types of NEWDECL and OLDDECL to |
| *NEWTYPEP and *OLDTYPEP - these may have been adjusted from |
| TREE_TYPE (NEWDECL, OLDDECL) respectively. */ |
| |
| static bool |
| diagnose_mismatched_decls (tree newdecl, tree olddecl, |
| tree *newtypep, tree *oldtypep) |
| { |
| tree newtype, oldtype; |
| bool pedwarned = false; |
| bool warned = false; |
| |
| /* If we have error_mark_node for either decl or type, just discard |
| the previous decl - we're in an error cascade already. */ |
| if (olddecl == error_mark_node || newdecl == error_mark_node) |
| return false; |
| *oldtypep = oldtype = TREE_TYPE (olddecl); |
| *newtypep = newtype = TREE_TYPE (newdecl); |
| if (oldtype == error_mark_node || newtype == error_mark_node) |
| return false; |
| |
| /* Two different categories of symbol altogether. This is an error |
| unless OLDDECL is a builtin. OLDDECL will be discarded in any case. */ |
| if (TREE_CODE (olddecl) != TREE_CODE (newdecl)) |
| { |
| if (TREE_CODE (olddecl) != FUNCTION_DECL |
| || !DECL_BUILT_IN (olddecl) || !C_DECL_INVISIBLE (olddecl)) |
| { |
| error ("%J'%D' redeclared as different kind of symbol", |
| newdecl, newdecl); |
| locate_old_decl (olddecl, error); |
| } |
| else if (TREE_PUBLIC (newdecl)) |
| warning ("%Jbuilt-in function '%D' declared as non-function", |
| newdecl, newdecl); |
| else if (warn_shadow) |
| warning ("%Jshadowing built-in function '%D'", |
| newdecl, newdecl); |
| return false; |
| } |
| |
| if (!comptypes (oldtype, newtype, COMPARE_STRICT)) |
| { |
| if (TREE_CODE (olddecl) == FUNCTION_DECL |
| && DECL_BUILT_IN (olddecl) && C_DECL_INVISIBLE (olddecl)) |
| { |
| /* Accept harmless mismatch in function types. |
| This is for the ffs and fprintf builtins. */ |
| tree trytype = match_builtin_function_types (newtype, oldtype); |
| |
| if (trytype && comptypes (newtype, trytype, COMPARE_STRICT)) |
| *oldtypep = oldtype = trytype; |
| else |
| { |
| /* If types don't match for a built-in, throw away the |
| built-in. No point in calling locate_old_decl here, it |
| won't print anything. */ |
| warning ("%Jconflicting types for built-in function '%D'", |
| newdecl, newdecl); |
| return false; |
| } |
| } |
| else if (TREE_CODE (olddecl) == FUNCTION_DECL |
| && DECL_SOURCE_LINE (olddecl) == 0) |
| { |
| /* A conflicting function declaration for a predeclared |
| function that isn't actually built in. Objective C uses |
| these. The new declaration silently overrides everything |
| but the volatility (i.e. noreturn) indication. See also |
| below. FIXME: Make Objective C use normal builtins. */ |
| TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl); |
| return false; |
| } |
| /* Permit void foo (...) to match int foo (...) if the latter is |
| the definition and implicit int was used. See |
| c-torture/compile/920625-2.c. */ |
| else if (TREE_CODE (newdecl) == FUNCTION_DECL && DECL_INITIAL (newdecl) |
| && TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == void_type_node |
| && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == integer_type_node |
| && C_FUNCTION_IMPLICIT_INT (newdecl)) |
| { |
| pedwarn ("%Jconflicting types for '%D'", newdecl, newdecl); |
| /* Make sure we keep void as the return type. */ |
| TREE_TYPE (newdecl) = *newtypep = newtype = oldtype; |
| C_FUNCTION_IMPLICIT_INT (newdecl) = 0; |
| pedwarned = true; |
| } |
| else |
| { |
| error ("%Jconflicting types for '%D'", newdecl, newdecl); |
| diagnose_arglist_conflict (newdecl, olddecl, newtype, oldtype); |
| locate_old_decl (olddecl, error); |
| return false; |
| } |
| } |
| |
| /* Redeclaration of a type is a constraint violation (6.7.2.3p1), |
| but silently ignore the redeclaration if either is in a system |
| header. (Conflicting redeclarations were handled above.) */ |
| if (TREE_CODE (newdecl) == TYPE_DECL) |
| { |
| if (DECL_IN_SYSTEM_HEADER (newdecl) || DECL_IN_SYSTEM_HEADER (olddecl)) |
| return true; /* allow OLDDECL to continue in use */ |
| |
| error ("%Jredefinition of typedef '%D'", newdecl, newdecl); |
| locate_old_decl (olddecl, error); |
| return false; |
| } |
| |
| /* Function declarations can either be 'static' or 'extern' (no |
| qualifier is equivalent to 'extern' - C99 6.2.2p5) and therefore |
| can never conflict with each other on account of linkage (6.2.2p4). |
| Multiple definitions are not allowed (6.9p3,5) but GCC permits |
| two definitions if one is 'extern inline' and one is not. The non- |
| extern-inline definition supersedes the extern-inline definition. */ |
| else if (TREE_CODE (newdecl) == FUNCTION_DECL) |
| { |
| /* If you declare a built-in function name as static, or |
| define the built-in with an old-style definition (so we |
| can't validate the argument list) the built-in definition is |
| overridden, but optionally warn this was a bad choice of name. */ |
| if (DECL_BUILT_IN (olddecl) |
| && C_DECL_INVISIBLE (olddecl) |
| && (!TREE_PUBLIC (newdecl) |
| || (DECL_INITIAL (newdecl) |
| && !TYPE_ARG_TYPES (TREE_TYPE (newdecl))))) |
| { |
| if (warn_shadow) |
| warning ("%Jshadowing built-in function '%D'", newdecl, newdecl); |
| /* Discard the old built-in function. */ |
| return false; |
| } |
| |
| if (DECL_INITIAL (newdecl)) |
| { |
| if (DECL_INITIAL (olddecl) |
| && !(DECL_DECLARED_INLINE_P (olddecl) |
| && DECL_EXTERNAL (olddecl) |
| && !(DECL_DECLARED_INLINE_P (newdecl) |
| && DECL_EXTERNAL (newdecl)))) |
| { |
| error ("%Jredefinition of '%D'", newdecl, newdecl); |
| locate_old_decl (olddecl, error); |
| return false; |
| } |
| } |
| /* If we have a prototype after an old-style function definition, |
| the argument types must be checked specially. */ |
| else if (DECL_INITIAL (olddecl) |
| && !TYPE_ARG_TYPES (oldtype) && TYPE_ARG_TYPES (newtype) |
| && TYPE_ACTUAL_ARG_TYPES (oldtype) |
| && !validate_proto_after_old_defn (newdecl, newtype, oldtype)) |
| { |
| locate_old_decl (olddecl, error); |
| return false; |
| } |
| /* Mismatched non-static and static is considered poor style. |
| We only diagnose static then non-static if -Wtraditional, |
| because it is the most convenient way to get some effects |
| (see e.g. what unwind-dw2-fde-glibc.c does to the definition |
| of _Unwind_Find_FDE in unwind-dw2-fde.c). Revisit? */ |
| if (TREE_PUBLIC (olddecl) && !TREE_PUBLIC (newdecl)) |
| { |
| /* A static function declaration for a predeclared function |
| that isn't actually built in, silently overrides the |
| default. Objective C uses these. See also above. |
| FIXME: Make Objective C use normal builtins. */ |
| if (TREE_CODE (olddecl) == FUNCTION_DECL |
| && DECL_SOURCE_LINE (olddecl) == 0) |
| return false; |
| else |
| { |
| warning ("%Jstatic declaration of '%D' follows " |
| "non-static declaration", newdecl, newdecl); |
| warned = true; |
| } |
| } |
| else if (TREE_PUBLIC (newdecl) && !TREE_PUBLIC (olddecl) |
| && warn_traditional) |
| { |
| warning ("%Jnon-static declaration of '%D' follows " |
| "static declaration", newdecl, newdecl); |
| warned = true; |
| } |
| } |
| else if (TREE_CODE (newdecl) == VAR_DECL) |
| { |
| /* Only variables can be thread-local, and all declarations must |
| agree on this property. */ |
| if (DECL_THREAD_LOCAL (newdecl) != DECL_THREAD_LOCAL (olddecl)) |
| { |
| if (DECL_THREAD_LOCAL (newdecl)) |
| error ("%Jthread-local declaration of '%D' follows " |
| "non-thread-local declaration", newdecl, newdecl); |
| else |
| error ("%Jnon-thread-local declaration of '%D' follows " |
| "thread-local declaration", newdecl, newdecl); |
| |
| locate_old_decl (olddecl, error); |
| return false; |
| } |
| |
| /* Multiple initialized definitions are not allowed (6.9p3,5). */ |
| if (DECL_INITIAL (newdecl) && DECL_INITIAL (olddecl)) |
| { |
| error ("%Jredefinition of '%D'", newdecl, newdecl); |
| locate_old_decl (olddecl, error); |
| return false; |
| } |
| |
| /* Objects declared at file scope: if at least one is 'extern', |
| it's fine (6.2.2p4); otherwise the linkage must agree (6.2.2p7). */ |
| if (DECL_FILE_SCOPE_P (newdecl)) |
| { |
| if (!DECL_EXTERNAL (newdecl) |
| && !DECL_EXTERNAL (olddecl) |
| && TREE_PUBLIC (newdecl) != TREE_PUBLIC (olddecl)) |
| { |
| if (TREE_PUBLIC (newdecl)) |
| error ("%Jnon-static declaration of '%D' follows " |
| "static declaration", newdecl, newdecl); |
| else |
| error ("%Jstatic declaration of '%D' follows " |
| "non-static declaration", newdecl, newdecl); |
| |
| locate_old_decl (olddecl, error); |
| return false; |
| } |
| } |
| /* Two objects with the same name declared at the same block |
| scope must both be external references (6.7p3). */ |
| else if (DECL_CONTEXT (newdecl) == DECL_CONTEXT (olddecl) |
| && (!DECL_EXTERNAL (newdecl) || !DECL_EXTERNAL (olddecl))) |
| { |
| if (DECL_EXTERNAL (newdecl)) |
| error ("%Jextern declaration of '%D' follows " |
| "declaration with no linkage", newdecl, newdecl); |
| else if (DECL_EXTERNAL (olddecl)) |
| error ("%Jdeclaration of '%D' with no linkage follows " |
| "extern declaration", newdecl, newdecl); |
| else |
| error ("%Jredeclaration of '%D' with no linkage", |
| newdecl, newdecl); |
| |
| locate_old_decl (olddecl, error); |
| return false; |
| } |
| } |
| |
| /* warnings */ |
| /* All decls must agree on a non-default visibility. */ |
| if (DECL_VISIBILITY (newdecl) != VISIBILITY_DEFAULT |
| && DECL_VISIBILITY (olddecl) != VISIBILITY_DEFAULT |
| && DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl)) |
| { |
| warning ("%Jredeclaration of '%D' with different visibility " |
| "(old visibility preserved)", newdecl, newdecl); |
| warned = true; |
| } |
| |
| if (TREE_CODE (newdecl) == FUNCTION_DECL) |
| { |
| /* Diagnose inline __attribute__ ((noinline)) which is silly. */ |
| if (DECL_DECLARED_INLINE_P (newdecl) |
| && lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl))) |
| { |
| warning ("%Jinline declaration of '%D' follows " |
| "declaration with attribute noinline", newdecl, newdecl); |
| warned = true; |
| } |
| else if (DECL_DECLARED_INLINE_P (olddecl) |
| && lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl))) |
| { |
| warning ("%Jdeclaration of '%D' with attribute noinline follows " |
| "inline declaration ", newdecl, newdecl); |
| warned = true; |
| } |
| |
| /* Inline declaration after use or definition. |
| ??? Should we still warn about this now we have unit-at-a-time |
| mode and can get it right? */ |
| if (DECL_DECLARED_INLINE_P (newdecl) && !DECL_DECLARED_INLINE_P (olddecl)) |
| { |
| if (TREE_USED (olddecl)) |
| { |
| warning ("%J'%D' declared inline after being called", |
| olddecl, olddecl); |
| warned = true; |
| } |
| else if (DECL_INITIAL (olddecl)) |
| { |
| warning ("%J'%D' declared inline after its definition", |
| olddecl, olddecl); |
| warned = true; |
| } |
| } |
| } |
| else /* PARM_DECL, VAR_DECL */ |
| { |
| /* Redeclaration of a PARM_DECL is invalid unless this is the |
| real position of a forward-declared parameter (GCC extension). */ |
| if (TREE_CODE (newdecl) == PARM_DECL |
| && (!TREE_ASM_WRITTEN (olddecl) || TREE_ASM_WRITTEN (newdecl))) |
| { |
| error ("%Jredefinition of parameter '%D'", newdecl, newdecl); |
| locate_old_decl (olddecl, error); |
| return false; |
| } |
| |
| /* These bits are only type qualifiers when applied to objects. */ |
| if (TREE_THIS_VOLATILE (newdecl) != TREE_THIS_VOLATILE (olddecl)) |
| { |
| if (TREE_THIS_VOLATILE (newdecl)) |
| pedwarn ("%Jvolatile declaration of '%D' follows " |
| "non-volatile declaration", newdecl, newdecl); |
| else |
| pedwarn ("%Jnon-volatile declaration of '%D' follows " |
| "volatile declaration", newdecl, newdecl); |
| pedwarned = true; |
| } |
| if (TREE_READONLY (newdecl) != TREE_READONLY (olddecl)) |
| { |
| if (TREE_READONLY (newdecl)) |
| pedwarn ("%Jconst declaration of '%D' follows " |
| "non-const declaration", newdecl, newdecl); |
| else |
| pedwarn ("%Jnon-const declaration of '%D' follows " |
| "const declaration", newdecl, newdecl); |
| pedwarned = true; |
| } |
| } |
| |
| /* Optional warning for completely redundant decls. */ |
| if (!warned && !pedwarned |
| && warn_redundant_decls |
| /* Don't warn about a function declaration followed by a |
| definition. */ |
| && !(TREE_CODE (newdecl) == FUNCTION_DECL |
| && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl)) |
| /* Don't warn about redundant redeclarations of builtins. */ |
| && !(TREE_CODE (newdecl) == FUNCTION_DECL |
| && !DECL_BUILT_IN (newdecl) |
| && DECL_BUILT_IN (olddecl) |
| && C_DECL_INVISIBLE (olddecl)) |
| /* Don't warn about an extern followed by a definition. */ |
| && !(DECL_EXTERNAL (olddecl) && !DECL_EXTERNAL (newdecl)) |
| /* Don't warn about forward parameter decls. */ |
| && !(TREE_CODE (newdecl) == PARM_DECL |
| && TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl))) |
| { |
| warning ("%Jredundant redeclaration of '%D'", newdecl, newdecl); |
| warned = true; |
| } |
| |
| /* Report location of previous decl/defn in a consistent manner. */ |
| if (warned || pedwarned) |
| locate_old_decl (olddecl, pedwarned ? pedwarn : warning); |
| |
| return true; |
| } |
| |
| /* Subroutine of duplicate_decls. NEWDECL has been found to be |
| consistent with OLDDECL, but carries new information. Merge the |
| new information into OLDDECL. This function issues no |
| diagnostics. */ |
| |
| static void |
| merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype) |
| { |
| int new_is_definition = (TREE_CODE (newdecl) == FUNCTION_DECL |
| && DECL_INITIAL (newdecl) != 0); |
| |
| /* For real parm decl following a forward decl, return 1 so old decl |
| will be reused. Only allow this to happen once. */ |
| if (TREE_CODE (newdecl) == PARM_DECL |
| && TREE_ASM_WRITTEN (olddecl) && ! TREE_ASM_WRITTEN (newdecl)) |
| { |
| TREE_ASM_WRITTEN (olddecl) = 0; |
| return; |
| } |
| |
| DECL_ATTRIBUTES (newdecl) |
| = (*targetm.merge_decl_attributes) (olddecl, newdecl); |
| |
| /* Merge the data types specified in the two decls. */ |
| TREE_TYPE (newdecl) |
| = TREE_TYPE (olddecl) |
| = common_type (newtype, oldtype); |
| |
| /* Lay the type out, unless already done. */ |
| if (oldtype != TREE_TYPE (newdecl)) |
| { |
| if (TREE_TYPE (newdecl) != error_mark_node) |
| layout_type (TREE_TYPE (newdecl)); |
| if (TREE_CODE (newdecl) != FUNCTION_DECL |
| && TREE_CODE (newdecl) != TYPE_DECL |
| && TREE_CODE (newdecl) != CONST_DECL) |
| layout_decl (newdecl, 0); |
| } |
| else |
| { |
| /* Since the type is OLDDECL's, make OLDDECL's size go with. */ |
| DECL_SIZE (newdecl) = DECL_SIZE (olddecl); |
| DECL_SIZE_UNIT (newdecl) = DECL_SIZE_UNIT (olddecl); |
| DECL_MODE (newdecl) = DECL_MODE (olddecl); |
| if (TREE_CODE (olddecl) != FUNCTION_DECL) |
| if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl)) |
| { |
| DECL_ALIGN (newdecl) = DECL_ALIGN (olddecl); |
| DECL_USER_ALIGN (newdecl) |= DECL_ALIGN (olddecl); |
| } |
| } |
| |
| /* Keep the old rtl since we can safely use it. */ |
| COPY_DECL_RTL (olddecl, newdecl); |
| |
| /* Merge the type qualifiers. */ |
| if (TREE_READONLY (newdecl)) |
| TREE_READONLY (olddecl) = 1; |
| |
| if (TREE_THIS_VOLATILE (newdecl)) |
| { |
| TREE_THIS_VOLATILE (olddecl) = 1; |
| if (TREE_CODE (newdecl) == VAR_DECL) |
| make_var_volatile (newdecl); |
| } |
| |
| /* Keep source location of definition rather than declaration. */ |
| if (DECL_INITIAL (newdecl) == 0 && DECL_INITIAL (olddecl) != 0) |
| DECL_SOURCE_LOCATION (newdecl) = DECL_SOURCE_LOCATION (olddecl); |
| |
| /* Merge the unused-warning information. */ |
| if (DECL_IN_SYSTEM_HEADER (olddecl)) |
| DECL_IN_SYSTEM_HEADER (newdecl) = 1; |
| else if (DECL_IN_SYSTEM_HEADER (newdecl)) |
| DECL_IN_SYSTEM_HEADER (olddecl) = 1; |
| |
| /* Merge the initialization information. */ |
| if (DECL_INITIAL (newdecl) == 0) |
| DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl); |
| |
| /* Merge the section attribute. |
| We want to issue an error if the sections conflict but that must be |
| done later in decl_attributes since we are called before attributes |
| are assigned. */ |
| if (DECL_SECTION_NAME (newdecl) == NULL_TREE) |
| DECL_SECTION_NAME (newdecl) = DECL_SECTION_NAME (olddecl); |
| |
| /* Copy the assembler name. |
| Currently, it can only be defined in the prototype. */ |
| COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl); |
| |
| /* If either declaration has a nondefault visibility, use it. */ |
| if (DECL_VISIBILITY (olddecl) != VISIBILITY_DEFAULT) |
| DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl); |
| |
| if (TREE_CODE (newdecl) == FUNCTION_DECL) |
| { |
| DECL_STATIC_CONSTRUCTOR(newdecl) |= DECL_STATIC_CONSTRUCTOR(olddecl); |
| DECL_STATIC_DESTRUCTOR (newdecl) |= DECL_STATIC_DESTRUCTOR (olddecl); |
| DECL_NO_LIMIT_STACK (newdecl) |= DECL_NO_LIMIT_STACK (olddecl); |
| DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (newdecl) |
| |= DECL_NO_INSTRUMENT_FUNCTION_ENTRY_EXIT (olddecl); |
| TREE_THIS_VOLATILE (newdecl) |= TREE_THIS_VOLATILE (olddecl); |
| TREE_READONLY (newdecl) |= TREE_READONLY (olddecl); |
| DECL_IS_MALLOC (newdecl) |= DECL_IS_MALLOC (olddecl); |
| DECL_IS_PURE (newdecl) |= DECL_IS_PURE (olddecl); |
| } |
| |
| /* Merge the storage class information. */ |
| merge_weak (newdecl, olddecl); |
| |
| /* For functions, static overrides non-static. */ |
| if (TREE_CODE (newdecl) == FUNCTION_DECL) |
| { |
| TREE_PUBLIC (newdecl) &= TREE_PUBLIC (olddecl); |
| /* This is since we don't automatically |
| copy the attributes of NEWDECL into OLDDECL. */ |
| TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl); |
| /* If this clears `static', clear it in the identifier too. */ |
| if (! TREE_PUBLIC (olddecl)) |
| TREE_PUBLIC (DECL_NAME (olddecl)) = 0; |
| } |
| if (DECL_EXTERNAL (newdecl)) |
| { |
| TREE_STATIC (newdecl) = TREE_STATIC (olddecl); |
| DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl); |
| |
| /* An extern decl does not override previous storage class. */ |
| TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl); |
| if (! DECL_EXTERNAL (newdecl)) |
| { |
| DECL_CONTEXT (newdecl) = DECL_CONTEXT (olddecl); |
| DECL_COMMON (newdecl) = DECL_COMMON (olddecl); |
| } |
| } |
| else |
| { |
| TREE_STATIC (olddecl) = TREE_STATIC (newdecl); |
| TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl); |
| } |
| |
| if (TREE_CODE (newdecl) == FUNCTION_DECL) |
| { |
| /* If we're redefining a function previously defined as extern |
| inline, make sure we emit debug info for the inline before we |
| throw it away, in case it was inlined into a function that hasn't |
| been written out yet. */ |
| if (new_is_definition && DECL_INITIAL (olddecl)) |
| { |
| if (TREE_USED (olddecl) |
| /* In unit-at-a-time mode we never inline re-defined extern |
| inline functions. */ |
| && !flag_unit_at_a_time |
| && cgraph_function_possibly_inlined_p (olddecl)) |
| (*debug_hooks->outlining_inline_function) (olddecl); |
| |
| /* The new defn must not be inline. */ |
| DECL_INLINE (newdecl) = 0; |
| DECL_UNINLINABLE (newdecl) = 1; |
| } |
| else |
| { |
| /* If either decl says `inline', this fn is inline, |
| unless its definition was passed already. */ |
| if (DECL_DECLARED_INLINE_P (newdecl) |
| || DECL_DECLARED_INLINE_P (olddecl)) |
| DECL_DECLARED_INLINE_P (newdecl) = 1; |
| |
| DECL_UNINLINABLE (newdecl) = DECL_UNINLINABLE (olddecl) |
| = (DECL_UNINLINABLE (newdecl) || DECL_UNINLINABLE (olddecl)); |
| } |
| |
| if (DECL_BUILT_IN (olddecl)) |
| { |
| /* If redeclaring a builtin function, it stays built in. */ |
| DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl); |
| DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl); |
| } |
| |
| /* Also preserve various other info from the definition. */ |
| if (! new_is_definition) |
| { |
| DECL_RESULT (newdecl) = DECL_RESULT (olddecl); |
| DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl); |
| DECL_SAVED_INSNS (newdecl) = DECL_SAVED_INSNS (olddecl); |
| DECL_SAVED_TREE (newdecl) = DECL_SAVED_TREE (olddecl); |
| DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl); |
| |
| /* Set DECL_INLINE on the declaration if we've got a body |
| from which to instantiate. */ |
| if (DECL_INLINE (olddecl) && ! DECL_UNINLINABLE (newdecl)) |
| { |
| DECL_INLINE (newdecl) = 1; |
| DECL_ABSTRACT_ORIGIN (newdecl) |
| = DECL_ABSTRACT_ORIGIN (olddecl); |
| } |
| } |
| else |
| { |
| /* If a previous declaration said inline, mark the |
| definition as inlinable. */ |
| if (DECL_DECLARED_INLINE_P (newdecl) |
| && ! DECL_UNINLINABLE (newdecl)) |
| DECL_INLINE (newdecl) = 1; |
| } |
| } |
| |
| /* Copy most of the decl-specific fields of NEWDECL into OLDDECL. |
| But preserve OLDDECL's DECL_UID and C_DECL_INVISIBLE. */ |
| { |
| unsigned olddecl_uid = DECL_UID (olddecl); |
| unsigned olddecl_invisible = C_DECL_INVISIBLE (olddecl); |
| |
| memcpy ((char *) olddecl + sizeof (struct tree_common), |
| (char *) newdecl + sizeof (struct tree_common), |
| sizeof (struct tree_decl) - sizeof (struct tree_common)); |
| DECL_UID (olddecl) = olddecl_uid; |
| C_DECL_INVISIBLE (olddecl) = olddecl_invisible; |
| } |
| |
| /* If OLDDECL had its DECL_RTL instantiated, re-invoke make_decl_rtl |
| so that encode_section_info has a chance to look at the new decl |
| flags and attributes. */ |
| if (DECL_RTL_SET_P (olddecl) |
| && (TREE_CODE (olddecl) == FUNCTION_DECL |
| || (TREE_CODE (olddecl) == VAR_DECL |
| && TREE_STATIC (olddecl)))) |
| make_decl_rtl (olddecl, NULL); |
| } |
| |
| /* Handle when a new declaration NEWDECL has the same name as an old |
| one OLDDECL in the same binding contour. Prints an error message |
| if appropriate. |
| |
| If safely possible, alter OLDDECL to look like NEWDECL, and return |
| true. Otherwise, return false. */ |
| |
| static bool |
| duplicate_decls (tree newdecl, tree olddecl) |
| { |
| tree newtype, oldtype; |
| |
| if (!diagnose_mismatched_decls (newdecl, olddecl, &newtype, &oldtype)) |
| return false; |
| |
| merge_decls (newdecl, olddecl, newtype, oldtype); |
| return true; |
| } |
| |
| |
| /* Return any external DECL associated with ID, whether or not it is |
| currently in scope. */ |
| |
| static tree |
| any_external_decl (tree id) |
| { |
| tree decl = IDENTIFIER_SYMBOL_VALUE (id); |
| tree t; |
| |
| if (decl == 0 || TREE_CODE (decl) == ERROR_MARK) |
| return 0; |
| else if (TREE_CODE (decl) != TYPE_DECL && DECL_EXTERNAL (decl)) |
| return decl; |
| |
| t = purpose_member (id, truly_local_externals); |
| if (t) |
| return TREE_VALUE (t); |
| |
| return 0; |
| } |
| |
| /* Record an external decl DECL. This only does something if a |
| shadowing decl already exists. */ |
| static void |
| record_external_decl (tree decl) |
| { |
| tree name = DECL_NAME (decl); |
| if (!IDENTIFIER_SYMBOL_VALUE (name)) |
| return; |
| |
| truly_local_externals = tree_cons (name, decl, truly_local_externals); |
| } |
| |
| /* Check whether decl-node X shadows an existing declaration. |
| OLD is the old IDENTIFIER_SYMBOL_VALUE of the DECL_NAME of X, |
| which might be a NULL_TREE. */ |
| static void |
| warn_if_shadowing (tree x, tree old) |
| { |
| /* Nothing to shadow? */ |
| if (old == 0 |
| /* Shadow warnings not wanted? */ |
| || !warn_shadow |
| /* No shadow warnings for internally generated vars. */ |
| || DECL_SOURCE_LINE (x) == 0 |
| /* No shadow warnings for vars made for inlining. */ |
| || DECL_FROM_INLINE (x) |
| /* Don't warn about the parm names in function declarator |
| within a function declarator. |
| It would be nice to avoid warning in any function |
| declarator in a declaration, as opposed to a definition, |
| but there is no way to tell it's not a definition. */ |
| || (TREE_CODE (x) == PARM_DECL && current_scope->outer->parm_flag) |
| /* Shadow warnings only apply to local variables and parameters. */ |
| || (TREE_CODE (x) != PARM_DECL && DECL_FILE_SCOPE_P (x))) |
| return; |
| |
| if (TREE_CODE (old) == PARM_DECL) |
| warning ("%Jdeclaration of '%D' shadows a parameter", x, x); |
| else if (DECL_FILE_SCOPE_P (old)) |
| warning ("%Jdeclaration of '%D' shadows a global declaration", x, x); |
| else |
| warning ("%Jdeclaration of '%D' shadows a previous local", x, x); |
| |
| warning ("%Jshadowed declaration is here", old); |
| } |
| |
| |
| /* Subroutine of pushdecl. |
| |
| X is a TYPE_DECL for a typedef statement. Create a brand new |
| ..._TYPE node (which will be just a variant of the existing |
| ..._TYPE node with identical properties) and then install X |
| as the TYPE_NAME of this brand new (duplicate) ..._TYPE node. |
| |
| The whole point here is to end up with a situation where each |
| and every ..._TYPE node the compiler creates will be uniquely |
| associated with AT MOST one node representing a typedef name. |
| This way, even though the compiler substitutes corresponding |
| ..._TYPE nodes for TYPE_DECL (i.e. "typedef name") nodes very |
| early on, later parts of the compiler can always do the reverse |
| translation and get back the corresponding typedef name. For |
| example, given: |
| |
| typedef struct S MY_TYPE; |
| MY_TYPE object; |
| |
| Later parts of the compiler might only know that `object' was of |
| type `struct S' if it were not for code just below. With this |
| code however, later parts of the compiler see something like: |
| |
| struct S' == struct S |
| typedef struct S' MY_TYPE; |
| struct S' object; |
| |
| And they can then deduce (from the node for type struct S') that |
| the original object declaration was: |
| |
| MY_TYPE object; |
| |
| Being able to do this is important for proper support of protoize, |
| and also for generating precise symbolic debugging information |
| which takes full account of the programmer's (typedef) vocabulary. |
| |
| Obviously, we don't want to generate a duplicate ..._TYPE node if |
| the TYPE_DECL node that we are now processing really represents a |
| standard built-in type. |
| |
| Since all standard types are effectively declared at line zero |
| in the source file, we can easily check to see if we are working |
| on a standard type by checking the current value of lineno. */ |
| |
| static void |
| clone_underlying_type (tree x) |
| { |
| if (DECL_SOURCE_LINE (x) == 0) |
| { |
| if (TYPE_NAME (TREE_TYPE (x)) == 0) |
| TYPE_NAME (TREE_TYPE (x)) = x; |
| } |
| else if (TREE_TYPE (x) != error_mark_node |
| && DECL_ORIGINAL_TYPE (x) == NULL_TREE) |
| { |
| tree tt = TREE_TYPE (x); |
| DECL_ORIGINAL_TYPE (x) = tt; |
| tt = build_type_copy (tt); |
| TYPE_NAME (tt) = x; |
| TREE_USED (tt) = TREE_USED (x); |
| TREE_TYPE (x) = tt; |
| } |
| } |
| |
| /* Record a decl-node X as belonging to the current lexical scope. |
| Check for errors (such as an incompatible declaration for the same |
| name already seen in the same scope). |
| |
| Returns either X or an old decl for the same name. |
| If an old decl is returned, it may have been smashed |
| to agree with what X says. */ |
| |
| tree |
| pushdecl (tree x) |
| { |
| tree name = DECL_NAME (x); |
| struct c_scope *scope = current_scope; |
| |
| #ifdef ENABLE_CHECKING |
| if (error_mark_node == 0) |
| /* Called too early. */ |
| abort (); |
| #endif |
| |
| /* Functions need the lang_decl data. */ |
| if (TREE_CODE (x) == FUNCTION_DECL && ! DECL_LANG_SPECIFIC (x)) |
| DECL_LANG_SPECIFIC (x) = ggc_alloc_cleared (sizeof (struct lang_decl)); |
| |
| /* A local extern declaration for a function doesn't constitute nesting. |
| A local auto declaration does, since it's a forward decl |
| for a nested function coming later. */ |
| if (current_function_decl == NULL |
| || ((TREE_CODE (x) == FUNCTION_DECL || TREE_CODE (x) == VAR_DECL) |
| && DECL_INITIAL (x) == 0 && DECL_EXTERNAL (x))) |
| DECL_CONTEXT (x) = current_file_decl; |
| else |
| DECL_CONTEXT (x) = current_function_decl; |
| |
| if (name) |
| { |
| tree old; |
| |
| if (warn_nested_externs |
| && scope != global_scope |
| && DECL_EXTERNAL (x) |
| && !DECL_IN_SYSTEM_HEADER (x)) |
| warning ("nested extern declaration of `%s'", |
| IDENTIFIER_POINTER (name)); |
| |
| old = lookup_name_current_level (name); |
| if (old && duplicate_decls (x, old)) |
| { |
| /* For PARM_DECLs, old may be a forward declaration. |
| If so, we want to remove it from its old location |
| (in the variables chain) and rechain it in the |
| location given by the new declaration. */ |
| if (TREE_CODE (x) == PARM_DECL) |
| { |
| tree *p; |
| for (p = &scope->names; *p; p = &TREE_CHAIN (*p)) |
| if (*p == old) |
| { |
| *p = TREE_CHAIN (old); |
| SCOPE_LIST_APPEND (scope, parms, old); |
| break; |
| } |
| } |
| return old; |
| } |
| if (DECL_EXTERNAL (x) || scope == global_scope) |
| { |
| /* Find and check against a previous, not-in-scope, external |
| decl for this identifier. (C99 6.2.7p2: All declarations |
| that refer to the same object or function shall have |
| compatible type; otherwise, the behavior is undefined.) */ |
| tree ext = any_external_decl (name); |
| if (ext) |
| { |
| if (duplicate_decls (x, ext)) |
| x = copy_node (ext); |
| } |
| else |
| record_external_decl (x); |
| } |
| |
| if (TREE_CODE (x) == TYPE_DECL) |
| clone_underlying_type (x); |
| |
| /* If storing a local value, there may already be one |
| (inherited). If so, record it for restoration when this |
| scope ends. Take care not to do this if we are replacing an |
| older decl in the same scope (i.e. duplicate_decls returned |
| false, above). */ |
| if (scope != global_scope) |
| { |
| tree inherited_decl = lookup_name (name); |
| if (inherited_decl && inherited_decl != old) |
| { |
| warn_if_shadowing (x, inherited_decl); |
| scope->shadowed = tree_cons (name, inherited_decl, |
| scope->shadowed); |
| } |
| } |
| |
| /* Install the new declaration in the requested scope. */ |
| IDENTIFIER_SYMBOL_VALUE (name) = x; |
| C_DECL_INVISIBLE (x) = 0; |
| |
| /* If x's type is incomplete because it's based on a |
| structure or union which has not yet been fully declared, |
| attach it to that structure or union type, so we can go |
| back and complete the variable declaration later, if the |
| structure or union gets fully declared. |
| |
| If the input is erroneous, we can have error_mark in the type |
| slot (e.g. "f(void a, ...)") - that doesn't count as an |
| incomplete type. */ |
| if (TREE_TYPE (x) != error_mark_node |
| && !COMPLETE_TYPE_P (TREE_TYPE (x))) |
| { |
| tree element = TREE_TYPE (x); |
| |
| while (TREE_CODE (element) == ARRAY_TYPE) |
| element = TREE_TYPE (element); |
| element = TYPE_MAIN_VARIANT (element); |
| |
| if ((TREE_CODE (element) == RECORD_TYPE |
| || TREE_CODE (element) == UNION_TYPE) |
| && (TREE_CODE (x) != TYPE_DECL |
| || TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE) |
| && !COMPLETE_TYPE_P (element)) |
| C_TYPE_INCOMPLETE_VARS (element) |
| = tree_cons (NULL_TREE, x, C_TYPE_INCOMPLETE_VARS (element)); |
| } |
| } |
| |
| if (TREE_CODE (x) == PARM_DECL) |
| SCOPE_LIST_APPEND (scope, parms, x); |
| else |
| SCOPE_LIST_APPEND (scope, names, x); |
| |
| return x; |
| } |
| |
| /* Record X as belonging to the global scope (C99 "file scope"). |
| This is used only internally by the Objective-C front end, |
| and is limited to its needs. duplicate_decls is not called; |
| if there is any preexisting decl for this identifier, it is an ICE. */ |
| |
| tree |
| pushdecl_top_level (tree x) |
| { |
| tree name; |
| |
| if (TREE_CODE (x) != VAR_DECL) |
| abort (); |
| |
| name = DECL_NAME (x); |
| |
| if (IDENTIFIER_SYMBOL_VALUE (name)) |
| abort (); |
| |
| DECL_CONTEXT (x) = current_file_decl; |
| IDENTIFIER_SYMBOL_VALUE (name) = x; |
| |
| SCOPE_LIST_APPEND (global_scope, names, x); |
| return x; |
| } |
| |
| /* Generate an implicit declaration for identifier FUNCTIONID as a |
| function of type int (). */ |
| |
| tree |
| implicitly_declare (tree functionid) |
| { |
| tree decl = any_external_decl (functionid); |
| |
| if (decl) |
| { |
| /* Implicit declaration of a function already declared |
| (somehow) in a different scope, or as a built-in. |
| If this is the first time this has happened, warn; |
| then recycle the old declaration. */ |
| if (!C_DECL_IMPLICIT (decl)) |
| { |
| implicit_decl_warning (DECL_NAME (decl)); |
| if (! DECL_FILE_SCOPE_P (decl)) |
| warning ("%Jprevious declaration of '%D'", decl, decl); |
| C_DECL_IMPLICIT (decl) = 1; |
| } |
| /* If this function is global, then it must already be in the |
| global scope, so there's no need to push it again. */ |
| if (current_scope == global_scope) |
| return decl; |
| /* If this is a local declaration, make a copy; we can't have |
| the same DECL listed in two different scopes. */ |
| return pushdecl (copy_node (decl)); |
| } |
| |
| /* Not seen before. */ |
| decl = build_decl (FUNCTION_DECL, functionid, default_function_type); |
| DECL_EXTERNAL (decl) = 1; |
| TREE_PUBLIC (decl) = 1; |
| C_DECL_IMPLICIT (decl) = 1; |
| implicit_decl_warning (functionid); |
| |
| /* C89 says implicit declarations are in the innermost block. |
| So we record the decl in the standard fashion. */ |
| decl = pushdecl (decl); |
| |
| /* No need to call objc_check_decl here - it's a function type. */ |
| rest_of_decl_compilation (decl, NULL, 0, 0); |
| |
| /* Write a record describing this implicit function declaration |
| to the prototypes file (if requested). */ |
| gen_aux_info_record (decl, 0, 1, 0); |
| |
| /* Possibly apply some default attributes to this implicit declaration. */ |
| decl_attributes (&decl, NULL_TREE, 0); |
| |
| return decl; |
| } |
| |
| static void |
| implicit_decl_warning (tree id) |
| { |
| const char *name = IDENTIFIER_POINTER (id); |
| if (mesg_implicit_function_declaration == 2) |
| error ("implicit declaration of function `%s'", name); |
| else if (mesg_implicit_function_declaration == 1) |
| warning ("implicit declaration of function `%s'", name); |
| } |
| |
| /* Issue an error message for a reference to an undeclared variable |
| ID, including a reference to a builtin outside of function-call |
| context. Establish a binding of the identifier to error_mark_node |
| in an appropriate scope, which will suppress further errors for the |
| same identifier. */ |
| void |
| undeclared_variable (tree id) |
| { |
| static bool already = false; |
| struct c_scope *scope; |
| |
| if (current_function_decl == 0) |
| { |
| error ("`%s' undeclared here (not in a function)", |
| IDENTIFIER_POINTER (id)); |
| scope = current_scope; |
| } |
| else |
| { |
| error ("`%s' undeclared (first use in this function)", |
| IDENTIFIER_POINTER (id)); |
| |
| if (! already) |
| { |
| error ("(Each undeclared identifier is reported only once"); |
| error ("for each function it appears in.)"); |
| already = true; |
| } |
| |
| scope = current_function_scope; |
| } |
| |
| scope->shadowed = tree_cons (id, IDENTIFIER_SYMBOL_VALUE (id), |
| scope->shadowed); |
| IDENTIFIER_SYMBOL_VALUE (id) = error_mark_node; |
| } |
| |
| /* Subroutine of lookup_label, declare_label, define_label: construct a |
| LABEL_DECL with all the proper frills. */ |
| |
| static tree |
| make_label (tree name, location_t location) |
| { |
| tree label = build_decl (LABEL_DECL, name, void_type_node); |
| |
| DECL_CONTEXT (label) = current_function_decl; |
| DECL_MODE (label) = VOIDmode; |
| DECL_SOURCE_LOCATION (label) = location; |
| |
| return label; |
| } |
| |
| /* Another subroutine of lookup_label, declare_label, define_label: |
| set up the binding of name to LABEL_DECL in the given SCOPE. */ |
| |
| static void |
| bind_label (tree name, tree label, struct c_scope *scope) |
| { |
| if (IDENTIFIER_LABEL_VALUE (name)) |
| scope->shadowed = tree_cons (name, IDENTIFIER_LABEL_VALUE (name), |
| scope->shadowed); |
| IDENTIFIER_LABEL_VALUE (name) = label; |
| |
| SCOPE_LIST_APPEND (scope, names, label); |
| } |
| |
| /* Get the LABEL_DECL corresponding to identifier NAME as a label. |
| Create one if none exists so far for the current function. |
| This is called when a label is used in a goto expression or |
| has its address taken. */ |
| |
| tree |
| lookup_label (tree name) |
| { |
| tree label; |
| |
| if (current_function_decl == 0) |
| { |
| error ("label %s referenced outside of any function", |
| IDENTIFIER_POINTER (name)); |
| return 0; |
| } |
| |
| /* Use a label already defined or ref'd with this name, but not if |
| it is inherited from a containing function and wasn't declared |
| using __label__. */ |
| label = IDENTIFIER_LABEL_VALUE (name); |
| if (label && (DECL_CONTEXT (label) == current_function_decl |
| || C_DECLARED_LABEL_FLAG (label))) |
| { |
| /* If the label has only been declared, update its apparent |
| location to point here, for better diagnostics if it |
| turns out not to have been defined. */ |
| if (!TREE_USED (label)) |
| DECL_SOURCE_LOCATION (label) = input_location; |
| return label; |
| } |
| |
| /* No label binding for that identifier; make one. */ |
| label = make_label (name, input_location); |
| |
| /* Ordinary labels go in the current function scope. */ |
| bind_label (name, label, current_function_scope); |
| return label; |
| } |
| |
| /* Make a label named NAME in the current function, shadowing silently |
| any that may be inherited from containing functions or containing |
| scopes. This is called for __label__ declarations. */ |
| |
| /* Note that valid use, if the label being shadowed comes from another |
| scope in the same function, requires calling declare_nonlocal_label |
| right away. (Is this still true? -zw 2003-07-17) */ |
| |
| tree |
| declare_label (tree name) |
| { |
| tree label = IDENTIFIER_LABEL_VALUE (name); |
| tree dup; |
| |
| /* Check to make sure that the label hasn't already been declared |
| at this scope */ |
| for (dup = current_scope->names; dup; dup = TREE_CHAIN (dup)) |
| if (dup == label) |
| { |
| error ("duplicate label declaration `%s'", IDENTIFIER_POINTER (name)); |
| error ("%Jthis is a previous declaration", dup); |
| |
| /* Just use the previous declaration. */ |
| return dup; |
| } |
| |
| label = make_label (name, input_location); |
| C_DECLARED_LABEL_FLAG (label) = 1; |
| |
| /* Declared labels go in the current scope. */ |
| bind_label (name, label, current_scope); |
| return label; |
| } |
| |
| /* Define a label, specifying the location in the source file. |
| Return the LABEL_DECL node for the label, if the definition is valid. |
| Otherwise return 0. */ |
| |
| tree |
| define_label (location_t location, tree name) |
| { |
| tree label; |
| |
| /* Find any preexisting label with this name. It is an error |
| if that label has already been defined in this function, or |
| if there is a containing function with a declared label with |
| the same name. */ |
| label = IDENTIFIER_LABEL_VALUE (name); |
| |
| if (label |
| && ((DECL_CONTEXT (label) == current_function_decl |
| && DECL_INITIAL (label) != 0) |
| || (DECL_CONTEXT (label) != current_function_decl |
| && C_DECLARED_LABEL_FLAG (label)))) |
| { |
| error ("%Hduplicate label `%D'", &location, label); |
| if (DECL_INITIAL (label)) |
| error ("%J`%D' previously defined here", label, label); |
| else |
| error ("%J`%D' previously declared here", label, label); |
| return 0; |
| } |
| else if (label && DECL_CONTEXT (label) == current_function_decl) |
| { |
| /* The label has been used or declared already in this function, |
| but not defined. Update its location to point to this |
| definition. */ |
| DECL_SOURCE_LOCATION (label) = location; |
| } |
| else |
| { |
| /* No label binding for that identifier; make one. */ |
| label = make_label (name, location); |
| |
| /* Ordinary labels go in the current function scope. */ |
| bind_label (name, label, current_function_scope); |
| } |
| |
| if (warn_traditional && !in_system_header && lookup_name (name)) |
| warning ("%Htraditional C lacks a separate namespace for labels, " |
| "identifier `%s' conflicts", &location, |
| IDENTIFIER_POINTER (name)); |
| |
| /* Mark label as having been defined. */ |
| DECL_INITIAL (label) = error_mark_node; |
| return label; |
| } |
| |
| /* Return the list of declarations of the current scope. */ |
| |
| tree |
| getdecls (void) |
| { |
| return current_scope->names; |
| } |
| |
| |
| /* Given NAME, an IDENTIFIER_NODE, |
| return the structure (or union or enum) definition for that name. |
| If THISLEVEL_ONLY is nonzero, searches only the current_scope. |
| CODE says which kind of type the caller wants; |
| it is RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE. |
| If the wrong kind of type is found, an error is reported. */ |
| |
| static tree |
| lookup_tag (enum tree_code code, tree name, int thislevel_only) |
| { |
| tree tag = IDENTIFIER_TAG_VALUE (name); |
| int thislevel = 0; |
| |
| if (!tag) |
| return 0; |
| |
| /* We only care about whether it's in this level if |
| thislevel_only was set or it might be a type clash. */ |
| if (thislevel_only || TREE_CODE (tag) != code) |
| { |
| if (current_scope == global_scope |
| || purpose_member (name, current_scope->tags)) |
| thislevel = 1; |
| } |
| |
| if (thislevel_only && !thislevel) |
| return 0; |
| |
| if (TREE_CODE (tag) != code) |
| { |
| /* Definition isn't the kind we were looking for. */ |
| pending_invalid_xref = name; |
| pending_invalid_xref_location = input_location; |
| |
| /* If in the same binding level as a declaration as a tag |
| of a different type, this must not be allowed to |
| shadow that tag, so give the error immediately. |
| (For example, "struct foo; union foo;" is invalid.) */ |
| if (thislevel) |
| pending_xref_error (); |
| } |
| return tag; |
| } |
| |
| /* Print an error message now |
| for a recent invalid struct, union or enum cross reference. |
| We don't print them immediately because they are not invalid |
| when used in the `struct foo;' construct for shadowing. */ |
| |
| void |
| pending_xref_error (void) |
| { |
| if (pending_invalid_xref != 0) |
| error ("%H`%s' defined as wrong kind of tag", |
| &pending_invalid_xref_location, |
| IDENTIFIER_POINTER (pending_invalid_xref)); |
| pending_invalid_xref = 0; |
| } |
| |
| |
| /* Look up NAME in the current scope and its superiors |
| in the namespace of variables, functions and typedefs. |
| Return a ..._DECL node of some kind representing its definition, |
| or return 0 if it is undefined. */ |
| |
| tree |
| lookup_name (tree name) |
| { |
| tree decl = IDENTIFIER_SYMBOL_VALUE (name); |
| if (decl == 0 || decl == error_mark_node) |
| return decl; |
| if (C_DECL_INVISIBLE (decl)) |
| return 0; |
| return decl; |
| } |
| |
| /* Similar to `lookup_name' but look only at the current scope. */ |
| |
| static tree |
| lookup_name_current_level (tree name) |
| { |
| tree decl = IDENTIFIER_SYMBOL_VALUE (name); |
| |
| if (decl == 0 || decl == error_mark_node || C_DECL_INVISIBLE (decl)) |
| return 0; |
| |
| if (current_scope == global_scope) |
| return decl; |
| |
| /* Scan the current scope for a decl with name NAME. |
| For PARM_DECLs, we have to look at both ->parms and ->names, since |
| forward parameter declarations wind up on the ->names list. */ |
| if (TREE_CODE (decl) == PARM_DECL |
| && chain_member (decl, current_scope->parms)) |
| return decl; |
| if (chain_member (decl, current_scope->names)) |
| return decl; |
| |
| return 0; |
| } |
| |
| /* Create the predefined scalar types of C, |
| and some nodes representing standard constants (0, 1, (void *) 0). |
| Initialize the global scope. |
| Make definitions for built-in primitive functions. */ |
| |
| void |
| c_init_decl_processing (void) |
| { |
| tree endlink; |
| tree ptr_ftype_void, ptr_ftype_ptr; |
| location_t save_loc = input_location; |
| |
| /* Adds some ggc roots, and reserved words for c-parse.in. */ |
| c_parse_init (); |
| |
| current_function_decl = 0; |
| |
| /* Make the c_scope structure for global names. */ |
| pushlevel (0); |
| global_scope = current_scope; |
| |
| /* Declarations from c_common_nodes_and_builtins must not be associated |
| with this input file, lest we get differences between using and not |
| using preprocessed headers. */ |
| input_location.file = "<internal>"; |
| input_location.line = 0; |
| |
| /* Make the DECL for the toplevel file scope. */ |
| current_file_decl = build_decl (TRANSLATION_UNIT_DECL, NULL, NULL); |
| |
| build_common_tree_nodes (flag_signed_char); |
| |
| c_common_nodes_and_builtins (); |
| |
| /* In C, comparisons and TRUTH_* expressions have type int. */ |
| truthvalue_type_node = integer_type_node; |
| truthvalue_true_node = integer_one_node; |
| truthvalue_false_node = integer_zero_node; |
| |
| /* Even in C99, which has a real boolean type. */ |
| pushdecl (build_decl (TYPE_DECL, get_identifier ("_Bool"), |
| boolean_type_node)); |
| |
| endlink = void_list_node; |
| ptr_ftype_void = build_function_type (ptr_type_node, endlink); |
| ptr_ftype_ptr |
| = build_function_type (ptr_type_node, |
| tree_cons (NULL_TREE, ptr_type_node, endlink)); |
| |
| input_location = save_loc; |
| |
| pedantic_lvalues = pedantic; |
| |
| make_fname_decl = c_make_fname_decl; |
| start_fname_decls (); |
| |
| first_builtin_decl = global_scope->names; |
| last_builtin_decl = global_scope->names_last; |
| } |
| |
| /* Create the VAR_DECL for __FUNCTION__ etc. ID is the name to give the |
| decl, NAME is the initialization string and TYPE_DEP indicates whether |
| NAME depended on the type of the function. As we don't yet implement |
| delayed emission of static data, we mark the decl as emitted |
| so it is not placed in the output. Anything using it must therefore pull |
| out the STRING_CST initializer directly. FIXME. */ |
| |
| static tree |
| c_make_fname_decl (tree id, int type_dep) |
| { |
| const char *name = fname_as_string (type_dep); |
| tree decl, type, init; |
| size_t length = strlen (name); |
| |
| type = build_array_type |
| (build_qualified_type (char_type_node, TYPE_QUAL_CONST), |
| build_index_type (size_int (length))); |
| |
| decl = build_decl (VAR_DECL, id, type); |
| |
| TREE_STATIC (decl) = 1; |
| TREE_READONLY (decl) = 1; |
| DECL_ARTIFICIAL (decl) = 1; |
| |
| init = build_string (length + 1, name); |
| TREE_TYPE (init) = type; |
| DECL_INITIAL (decl) = init; |
| |
| TREE_USED (decl) = 1; |
| |
| if (current_function_decl) |
| { |
| DECL_CONTEXT (decl) = current_function_decl; |
| IDENTIFIER_SYMBOL_VALUE (id) = decl; |
| SCOPE_LIST_APPEND (current_function_scope, names, decl); |
| } |
| |
| finish_decl (decl, init, NULL_TREE); |
| |
| return decl; |
| } |
| |
| /* Return a definition for a builtin function named NAME and whose data type |
| is TYPE. TYPE should be a function type with argument types. |
| FUNCTION_CODE tells later passes how to compile calls to this function. |
| See tree.h for its possible values. |
| |
| If LIBRARY_NAME is nonzero, use that for DECL_ASSEMBLER_NAME, |
| the name to be called if we can't opencode the function. If |
| ATTRS is nonzero, use that for the function's attribute list. */ |
| |
| tree |
| builtin_function (const char *name, tree type, int function_code, |
| enum built_in_class class, const char *library_name, |
| tree attrs) |
| { |
| tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type); |
| DECL_EXTERNAL (decl) = 1; |
| TREE_PUBLIC (decl) = 1; |
| if (library_name) |
| SET_DECL_ASSEMBLER_NAME (decl, get_identifier (library_name)); |
| make_decl_rtl (decl, NULL); |
| pushdecl (decl); |
| DECL_BUILT_IN_CLASS (decl) = class; |
| DECL_FUNCTION_CODE (decl) = function_code; |
| |
| /* Warn if a function in the namespace for users |
| is used without an occasion to consider it declared. */ |
| if (name[0] != '_' || name[1] != '_') |
| C_DECL_INVISIBLE (decl) = 1; |
| |
| /* Possibly apply some default attributes to this built-in function. */ |
| if (attrs) |
| decl_attributes (&decl, attrs, ATTR_FLAG_BUILT_IN); |
| else |
| decl_attributes (&decl, NULL_TREE, 0); |
| |
| return decl; |
| } |
| |
| /* Called when a declaration is seen that contains no names to declare. |
| If its type is a reference to a structure, union or enum inherited |
| from a containing scope, shadow that tag name for the current scope |
| with a forward reference. |
| If its type defines a new named structure or union |
| or defines an enum, it is valid but we need not do anything here. |
| Otherwise, it is an error. */ |
| |
| void |
| shadow_tag (tree declspecs) |
| { |
| shadow_tag_warned (declspecs, 0); |
| } |
| |
| void |
| shadow_tag_warned (tree declspecs, int warned) |
| |
| |
| /* 1 => we have done a pedwarn. 2 => we have done a warning, but |
| no pedwarn. */ |
| { |
| int found_tag = 0; |
| tree link; |
| tree specs, attrs; |
| |
| pending_invalid_xref = 0; |
| |
| /* Remove the attributes from declspecs, since they will confuse the |
| following code. */ |
| split_specs_attrs (declspecs, &specs, &attrs); |
| |
| for (link = specs; link; link = TREE_CHAIN (link)) |
| { |
| tree value = TREE_VALUE (link); |
| enum tree_code code = TREE_CODE (value); |
| |
| if (code == RECORD_TYPE || code == UNION_TYPE || code == ENUMERAL_TYPE) |
| /* Used to test also that TYPE_SIZE (value) != 0. |
| That caused warning for `struct foo;' at top level in the file. */ |
| { |
| tree name = TYPE_NAME (value); |
| tree t; |
| |
| found_tag++; |
| |
| if (name == 0) |
| { |
| if (warned != 1 && code != ENUMERAL_TYPE) |
| /* Empty unnamed enum OK */ |
| { |
| pedwarn ("unnamed struct/union that defines no instances"); |
| warned = 1; |
| } |
| } |
| else |
| { |
| t = lookup_tag (code, name, 1); |
| |
| if (t == 0) |
| { |
| t = make_node (code); |
| pushtag (name, t); |
| } |
| } |
| } |
| else |
| { |
| if (!warned && ! in_system_header) |
| { |
| warning ("useless keyword or type name in empty declaration"); |
| warned = 2; |
| } |
| } |
| } |
| |
| if (found_tag > 1) |
| error ("two types specified in one empty declaration"); |
| |
| if (warned != 1) |
| { |
| if (found_tag == 0) |
| pedwarn ("empty declaration"); |
| } |
| } |
| |
| /* Construct an array declarator. EXPR is the expression inside [], or |
| NULL_TREE. QUALS are the type qualifiers inside the [] (to be applied |
| to the pointer to which a parameter array is converted). STATIC_P is |
| nonzero if "static" is inside the [], zero otherwise. VLA_UNSPEC_P |
| is nonzero is the array is [*], a VLA of unspecified length which is |
| nevertheless a complete type (not currently implemented by GCC), |
| zero otherwise. The declarator is constructed as an ARRAY_REF |
| (to be decoded by grokdeclarator), whose operand 0 is what's on the |
| left of the [] (filled by in set_array_declarator_type) and operand 1 |
| is the expression inside; whose TREE_TYPE is the type qualifiers and |
| which has TREE_STATIC set if "static" is used. */ |
| |
| tree |
| build_array_declarator (tree expr, tree quals, int static_p, int vla_unspec_p) |
| { |
| tree decl; |
| decl = build_nt (ARRAY_REF, NULL_TREE, expr); |
| TREE_TYPE (decl) = quals; |
| TREE_STATIC (decl) = (static_p ? 1 : 0); |
| if (pedantic && !flag_isoc99) |
| { |
| if (static_p || quals != NULL_TREE) |
| pedwarn ("ISO C90 does not support `static' or type qualifiers in parameter array declarators"); |
| if (vla_unspec_p) |
| pedwarn ("ISO C90 does not support `[*]' array declarators"); |
| } |
| if (vla_unspec_p) |
| warning ("GCC does not yet properly implement `[*]' array declarators"); |
| return decl; |
| } |
| |
| /* Set the type of an array declarator. DECL is the declarator, as |
| constructed by build_array_declarator; TYPE is what appears on the left |
| of the [] and goes in operand 0. ABSTRACT_P is nonzero if it is an |
| abstract declarator, zero otherwise; this is used to reject static and |
| type qualifiers in abstract declarators, where they are not in the |
| C99 grammar. */ |
| |
| tree |
| set_array_declarator_type (tree decl, tree type, int abstract_p) |
| { |
| TREE_OPERAND (decl, 0) = type; |
| if (abstract_p && (TREE_TYPE (decl) != NULL_TREE || TREE_STATIC (decl))) |
| error ("static or type qualifiers in abstract declarator"); |
| return decl; |
| } |
| |
| /* Decode a "typename", such as "int **", returning a ..._TYPE node. */ |
| |
| tree |
| groktypename (tree typename) |
| { |
| tree specs, attrs; |
| |
| if (TREE_CODE (typename) != TREE_LIST) |
| return typename; |
| |
| split_specs_attrs (TREE_PURPOSE (typename), &specs, &attrs); |
| |
| typename = grokdeclarator (TREE_VALUE (typename), specs, TYPENAME, 0, |
| NULL); |
| |
| /* Apply attributes. */ |
| decl_attributes (&typename, attrs, 0); |
| |
| return typename; |
| } |
| |
| /* Return a PARM_DECL node for a given pair of specs and declarator. */ |
| |
| tree |
| groktypename_in_parm_context (tree typename) |
| { |
| if (TREE_CODE (typename) != TREE_LIST) |
| return typename; |
| return grokdeclarator (TREE_VALUE (typename), |
| TREE_PURPOSE (typename), |
| PARM, 0, NULL); |
| } |
| |
| /* Decode a declarator in an ordinary declaration or data definition. |
| This is called as soon as the type information and variable name |
| have been parsed, before parsing the initializer if any. |
| Here we create the ..._DECL node, fill in its type, |
| and put it on the list of decls for the current context. |
| The ..._DECL node is returned as the value. |
| |
| Exception: for arrays where the length is not specified, |
| the type is left null, to be filled in by `finish_decl'. |
| |
| Function definitions do not come here; they go to start_function |
| instead. However, external and forward declarations of functions |
| do go through here. Structure field declarations are done by |
| grokfield and not through here. */ |
| |
| tree |
| start_decl (tree declarator, tree declspecs, int initialized, tree attributes) |
| { |
| tree decl; |
| tree tem; |
| |
| /* An object declared as __attribute__((deprecated)) suppresses |
| warnings of uses of other deprecated items. */ |
| if (lookup_attribute ("deprecated", attributes)) |
| deprecated_state = DEPRECATED_SUPPRESS; |
| |
| decl = grokdeclarator (declarator, declspecs, |
| NORMAL, initialized, NULL); |
| |
| deprecated_state = DEPRECATED_NORMAL; |
| |
| if (warn_main > 0 && TREE_CODE (decl) != FUNCTION_DECL |
| && MAIN_NAME_P (DECL_NAME (decl))) |
| warning ("%J'%D' is usually a function", decl, decl); |
| |
| if (initialized) |
| /* Is it valid for this decl to have an initializer at all? |
| If not, set INITIALIZED to zero, which will indirectly |
| tell `finish_decl' to ignore the initializer once it is parsed. */ |
| switch (TREE_CODE (decl)) |
| { |
| case TYPE_DECL: |
| error ("typedef `%s' is initialized (use __typeof__ instead)", |
| IDENTIFIER_POINTER (DECL_NAME (decl))); |
| initialized = 0; |
| break; |
| |
| case FUNCTION_DECL: |
| error ("function `%s' is initialized like a variable", |
| IDENTIFIER_POINTER (DECL_NAME (decl))); |
| initialized = 0; |
| break; |
| |
| case PARM_DECL: |
| /* DECL_INITIAL in a PARM_DECL is really DECL_ARG_TYPE. */ |
| error ("parameter `%s' is initialized", |
| IDENTIFIER_POINTER (DECL_NAME (decl))); |
| initialized = 0; |
| break; |
| |
| default: |
| /* Don't allow initializations for incomplete types |
| except for arrays which might be completed by the initialization. */ |
| |
| /* This can happen if the array size is an undefined macro. We already |
| gave a warning, so we don't need another one. */ |
| if (TREE_TYPE (decl) == error_mark_node) |
| initialized = 0; |
| else if (COMPLETE_TYPE_P (TREE_TYPE (decl))) |
| { |
| /* A complete type is ok if size is fixed. */ |
| |
| if (TREE_CODE (TYPE_SIZE (TREE_TYPE (decl))) != INTEGER_CST |
| || C_DECL_VARIABLE_SIZE (decl)) |
| { |
| error ("variable-sized object may not be initialized"); |
| initialized = 0; |
| } |
| } |
| else if (TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE) |
| { |
| error ("variable `%s' has initializer but incomplete type", |
| IDENTIFIER_POINTER (DECL_NAME (decl))); |
| initialized = 0; |
| } |
| else if (!COMPLETE_TYPE_P (TREE_TYPE (TREE_TYPE (decl)))) |
| { |
| error ("elements of array `%s' have incomplete type", |
| IDENTIFIER_POINTER (DECL_NAME (decl))); |
| initialized = 0; |
| } |
| } |
| |
| if (initialized) |
| { |
| DECL_EXTERNAL (decl) = 0; |
| if (current_scope == global_scope) |
| TREE_STATIC (decl) = 1; |
| |
| /* Tell `pushdecl' this is an initialized decl |
| even though we don't yet have the initializer expression. |
| Also tell `finish_decl' it may store the real initializer. */ |
| DECL_INITIAL (decl) = error_mark_node; |
| } |
| |
| /* If this is a function declaration, write a record describing it to the |
| prototypes file (if requested). */ |
| |
| if (TREE_CODE (decl) == FUNCTION_DECL) |
| gen_aux_info_record (decl, 0, 0, TYPE_ARG_TYPES (TREE_TYPE (decl)) != 0); |
| |
| /* ANSI specifies that a tentative definition which is not merged with |
| a non-tentative definition behaves exactly like a definition with an |
| initializer equal to zero. (Section 3.7.2) |
| |
| -fno-common gives strict ANSI behavior, though this tends to break |
| a large body of code that grew up without this rule. |
| |
| Thread-local variables are never common, since there's no entrenched |
| body of code to break, and it allows more efficient variable references |
| in the presence of dynamic linking. */ |
| |
| if (TREE_CODE (decl) == VAR_DECL |
| && !initialized |
| && TREE_PUBLIC (decl) |
| && !DECL_THREAD_LOCAL (decl) |
| && !flag_no_common) |
| DECL_COMMON (decl) = 1; |
| |
| /* Set attributes here so if duplicate decl, will have proper attributes. */ |
| decl_attributes (&decl, attributes, 0); |
| |
| if (TREE_CODE (decl) == FUNCTION_DECL |
| && targetm.calls.promote_prototypes (TREE_TYPE (decl))) |
| { |
| tree ce = declarator; |
| |
| if (TREE_CODE (ce) == INDIRECT_REF) |
| ce = TREE_OPERAND (declarator, 0); |
| if (TREE_CODE (ce) == CALL_EXPR) |
| { |
| tree args = TREE_PURPOSE (TREE_OPERAND (ce, 1)); |
| for (; args; args = TREE_CHAIN (args)) |
| { |
| tree type = TREE_TYPE (args); |
| if (INTEGRAL_TYPE_P (type) |
| && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)) |
| DECL_ARG_TYPE (args) = integer_type_node; |
| } |
| } |
| } |
| |
| if (TREE_CODE (decl) == FUNCTION_DECL |
| && DECL_DECLARED_INLINE_P (decl) |
| && DECL_UNINLINABLE (decl) |
| && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl))) |
| warning ("%Jinline function '%D' given attribute noinline", decl, decl); |
| |
| /* Add this decl to the current scope. |
| TEM may equal DECL or it may be a previous decl of the same name. */ |
| tem = pushdecl (decl); |
| |
| /* For a local variable, define the RTL now. */ |
| if (current_scope != global_scope |
| /* But not if this is a duplicate decl |
| and we preserved the rtl from the previous one |
| (which may or may not happen). */ |
| && !DECL_RTL_SET_P (tem) |
| && DECL_FILE_SCOPE_P (tem)) |
| { |
| if (TREE_TYPE (tem) != error_mark_node |
| && (COMPLETE_TYPE_P (TREE_TYPE (tem)) |
| || (TREE_CODE (TREE_TYPE (tem)) == ARRAY_TYPE |
| && DECL_INITIAL (tem) != 0))) |
| expand_decl (tem); |
| } |
| |
| return tem; |
| } |
| |
| /* Finish processing of a declaration; |
| install its initial value. |
| If the length of an array type is not known before, |
| it must be determined now, from the initial value, or it is an error. */ |
| |
| void |
| finish_decl (tree decl, tree init, tree asmspec_tree) |
| { |
| tree type = TREE_TYPE (decl); |
| int was_incomplete = (DECL_SIZE (decl) == 0); |
| const char *asmspec = 0; |
| |
| /* If a name was specified, get the string. */ |
| if (current_scope == global_scope) |
| asmspec_tree = maybe_apply_renaming_pragma (decl, asmspec_tree); |
| if (asmspec_tree) |
| asmspec = TREE_STRING_POINTER (asmspec_tree); |
| |
| /* If `start_decl' didn't like having an initialization, ignore it now. */ |
| if (init != 0 && DECL_INITIAL (decl) == 0) |
| init = 0; |
| |
| /* Don't crash if parm is initialized. */ |
| if (TREE_CODE (decl) == PARM_DECL) |
| init = 0; |
| |
| if (init) |
| store_init_value (decl, init); |
| |
| if (c_dialect_objc () && (TREE_CODE (decl) == VAR_DECL |
| || TREE_CODE (decl) == FUNCTION_DECL |
| || TREE_CODE (decl) == FIELD_DECL)) |
| objc_check_decl (decl); |
| |
| /* Deduce size of array from initialization, if not already known. */ |
| if (TREE_CODE (type) == ARRAY_TYPE |
| && TYPE_DOMAIN (type) == 0 |
| && TREE_CODE (decl) != TYPE_DECL) |
| { |
| int do_default |
| = (TREE_STATIC (decl) |
| /* Even if pedantic, an external linkage array |
| may have incomplete type at first. */ |
| ? pedantic && !TREE_PUBLIC (decl) |
| : !DECL_EXTERNAL (decl)); |
| int failure |
| = complete_array_type (type, DECL_INITIAL (decl), do_default); |
| |
| /* Get the completed type made by complete_array_type. */ |
| type = TREE_TYPE (decl); |
| |
| if (failure == 1) |
| error ("%Jinitializer fails to determine size of '%D'", decl, decl); |
| |
| else if (failure == 2) |
| { |
| if (do_default) |
| error ("%Jarray size missing in '%D'", decl, decl); |
| /* If a `static' var's size isn't known, |
| make it extern as well as static, so it does not get |
| allocated. |
| If it is not `static', then do not mark extern; |
| finish_incomplete_decl will give it a default size |
| and it will get allocated. */ |
| else if (!pedantic && TREE_STATIC (decl) && ! TREE_PUBLIC (decl)) |
| DECL_EXTERNAL (decl) = 1; |
| } |
| |
| /* TYPE_MAX_VALUE is always one less than the number of elements |
| in the array, because we start counting at zero. Therefore, |
| warn only if the value is less than zero. */ |
| else if (pedantic && TYPE_DOMAIN (type) != 0 |
| && tree_int_cst_sgn (TYPE_MAX_VALUE (TYPE_DOMAIN (type))) < 0) |
| error ("%Jzero or negative size array '%D'", decl, decl); |
| |
| layout_decl (decl, 0); |
| } |
| |
| if (TREE_CODE (decl) == VAR_DECL) |
| { |
| if (DECL_SIZE (decl) == 0 && TREE_TYPE (decl) != error_mark_node |
| && COMPLETE_TYPE_P (TREE_TYPE (decl))) |
| layout_decl (decl, 0); |
| |
| if (DECL_SIZE (decl) == 0 |
| /* Don't give an error if we already gave one earlier. */ |
| && TREE_TYPE (decl) != error_mark_node |
| && (TREE_STATIC (decl) |
| ? |
| /* A static variable with an incomplete type |
| is an error if it is initialized. |
| Also if it is not file scope. |
| Otherwise, let it through, but if it is not `extern' |
| then it may cause an error message later. */ |
| (DECL_INITIAL (decl) != 0 |
| || !DECL_FILE_SCOPE_P (decl)) |
| : |
| /* An automatic variable with an incomplete type |
| is an error. */ |
| !DECL_EXTERNAL (decl))) |
| { |
| error ("%Jstorage size of '%D' isn't known", decl, decl); |
| TREE_TYPE (decl) = error_mark_node; |
| } |
| |
| if ((DECL_EXTERNAL (decl) || TREE_STATIC (decl)) |
| && DECL_SIZE (decl) != 0) |
| { |
| if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST) |
| constant_expression_warning (DECL_SIZE (decl)); |
| else |
| error ("%Jstorage size of '%D' isn't constant", decl, decl); |
| } |
| |
| if (TREE_USED (type)) |
| TREE_USED (decl) = 1; |
| } |
| |
| /* If this is a function and an assembler name is specified, reset DECL_RTL |
| so we can give it its new name. Also, update built_in_decls if it |
| was a normal built-in. */ |
| if (TREE_CODE (decl) == FUNCTION_DECL && asmspec) |
| { |
| /* ASMSPEC is given, and not the name of a register. Mark the |
| name with a star so assemble_name won't munge it. */ |
| char *starred = alloca (strlen (asmspec) + 2); |
| starred[0] = '*'; |
| strcpy (starred + 1, asmspec); |
| |
| if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL) |
| { |
| tree builtin = built_in_decls [DECL_FUNCTION_CODE (decl)]; |
| SET_DECL_RTL (builtin, NULL_RTX); |
| SET_DECL_ASSEMBLER_NAME (builtin, get_identifier (starred)); |
| #ifdef TARGET_MEM_FUNCTIONS |
| if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMCPY) |
| init_block_move_fn (starred); |
| else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_MEMSET) |
| init_block_clear_fn (starred); |
| #else |
| if (DECL_FUNCTION_CODE (decl) == BUILT_IN_BCOPY) |
| init_block_move_fn (starred); |
| else if (DECL_FUNCTION_CODE (decl) == BUILT_IN_BZERO) |
| init_block_clear_fn (starred); |
| #endif |
| } |
| SET_DECL_RTL (decl, NULL_RTX); |
| change_decl_assembler_name (decl, get_identifier (starred)); |
| } |
| |
| /* If #pragma weak was used, mark the decl weak now. */ |
| if (current_scope == global_scope) |
| maybe_apply_pragma_weak (decl); |
| |
| /* Output the assembler code and/or RTL code for variables and functions, |
| unless the type is an undefined structure or union. |
| If not, it will get done when the type is completed. */ |
| |
| if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL) |
| { |
| /* This is a no-op in c-lang.c or something real in objc-act.c. */ |
| if (c_dialect_objc ()) |
| objc_check_decl (decl); |
| |
| if (DECL_FILE_SCOPE_P (decl)) |
| { |
| if (DECL_INITIAL (decl) == NULL_TREE |
| || DECL_INITIAL (decl) == error_mark_node) |
| /* Don't output anything |
| when a tentative file-scope definition is seen. |
| But at end of compilation, do output code for them. */ |
| DECL_DEFER_OUTPUT (decl) = 1; |
| rest_of_decl_compilation (decl, asmspec, true, 0); |
| } |
| else |
| { |
| /* This is a local variable. If there is an ASMSPEC, the |
| user has requested that we handle it specially. */ |
| if (asmspec) |
| { |
| /* In conjunction with an ASMSPEC, the `register' |
| keyword indicates that we should place the variable |
| in a particular register. */ |
| if (DECL_REGISTER (decl)) |
| DECL_C_HARD_REGISTER (decl) = 1; |
| |
| /* If this is not a static variable, issue a warning. |
| It doesn't make any sense to give an ASMSPEC for an |
| ordinary, non-register local variable. Historically, |
| GCC has accepted -- but ignored -- the ASMSPEC in |
| this case. */ |
| if (TREE_CODE (decl) == VAR_DECL |
| && !DECL_REGISTER (decl) |
| && !TREE_STATIC (decl)) |
| warning ("%Jignoring asm-specifier for non-static local " |
| "variable '%D'", decl, decl); |
| else |
| change_decl_assembler_name (decl, get_identifier (asmspec)); |
| } |
| |
| if (TREE_CODE (decl) != FUNCTION_DECL) |
| add_decl_stmt (decl); |
| } |
| |
| if (!DECL_FILE_SCOPE_P (decl)) |
| { |
| /* Recompute the RTL of a local array now |
| if it used to be an incomplete type. */ |
| if (was_incomplete |
| && ! TREE_STATIC (decl) && ! DECL_EXTERNAL (decl)) |
| { |
| /* If we used it already as memory, it must stay in memory. */ |
| TREE_ADDRESSABLE (decl) = TREE_USED (decl); |
| /* If it's still incomplete now, no init will save it. */ |
| if (DECL_SIZE (decl) == 0) |
| DECL_INITIAL (decl) = 0; |
| } |
| } |
| } |
| |
| /* If this was marked 'used', be sure it will be output. */ |
| if (lookup_attribute ("used", DECL_ATTRIBUTES (decl))) |
| mark_referenced (DECL_ASSEMBLER_NAME (decl)); |
| |
| if (TREE_CODE (decl) == TYPE_DECL) |
| rest_of_decl_compilation (decl, NULL, DECL_FILE_SCOPE_P (decl), 0); |
| |
| /* At the end of a declaration, throw away any variable type sizes |
| of types defined inside that declaration. There is no use |
| computing them in the following function definition. */ |
| if (current_scope == global_scope) |
| get_pending_sizes (); |
| |
| /* Install a cleanup (aka destructor) if one was given. */ |
| if (TREE_CODE (decl) == VAR_DECL && !TREE_STATIC (decl)) |
| { |
| tree attr = lookup_attribute ("cleanup", DECL_ATTRIBUTES (decl)); |
| if (attr) |
| { |
| static bool eh_initialized_p; |
| |
| tree cleanup_id = TREE_VALUE (TREE_VALUE (attr)); |
| tree cleanup_decl = lookup_name (cleanup_id); |
| tree cleanup; |
| |
| /* Build "cleanup(&decl)" for the destructor. */ |
| cleanup = build_unary_op (ADDR_EXPR, decl, 0); |
| cleanup = build_tree_list (NULL_TREE, cleanup); |
| cleanup = build_function_call (cleanup_decl, cleanup); |
| |
| /* Don't warn about decl unused; the cleanup uses it. */ |
| TREE_USED (decl) = 1; |
| |
| /* Initialize EH, if we've been told to do so. */ |
| if (flag_exceptions && !eh_initialized_p) |
| { |
| eh_initialized_p = true; |
| eh_personality_libfunc |
| = init_one_libfunc (USING_SJLJ_EXCEPTIONS |
| ? "__gcc_personality_sj0" |
| : "__gcc_personality_v0"); |
| using_eh_for_cleanups (); |
| } |
| |
| add_stmt (build_stmt (CLEANUP_STMT, decl, cleanup)); |
| } |
| } |
| } |
| |
| /* Given a parsed parameter declaration, decode it into a PARM_DECL |
| and push that on the current scope. */ |
| |
| void |
| push_parm_decl (tree parm) |
| { |
| tree decl; |
| |
| /* Don't attempt to expand sizes while parsing this decl. |
| (We can get here with i_s_e 1 somehow from Objective-C.) */ |
| int save_immediate_size_expand = immediate_size_expand; |
| immediate_size_expand = 0; |
| |
| decl = grokdeclarator (TREE_VALUE (TREE_PURPOSE (parm)), |
| TREE_PURPOSE (TREE_PURPOSE (parm)), |
| PARM, 0, NULL); |
| decl_attributes (&decl, TREE_VALUE (parm), 0); |
| |
| decl = pushdecl (decl); |
| |
| finish_decl (decl, NULL_TREE, NULL_TREE); |
| |
| immediate_size_expand = save_immediate_size_expand; |
| } |
| |
| /* Mark all the parameter declarations to date as forward decls, |
| shift them to the variables list, and reset the parameters list. |
| Also diagnose use of this extension. */ |
| |
| void |
| mark_forward_parm_decls (void) |
| { |
| tree parm; |
| |
| if (pedantic && !current_scope->warned_forward_parm_decls) |
| { |
| pedwarn ("ISO C forbids forward parameter declarations"); |
| current_scope->warned_forward_parm_decls = true; |
| } |
| |
| for (parm = current_scope->parms; parm; parm = TREE_CHAIN (parm)) |
| TREE_ASM_WRITTEN (parm) = 1; |
| |
| SCOPE_LIST_CONCAT (current_scope, names, current_scope, parms); |
| current_scope->parms = 0; |
| current_scope->parms_last = 0; |
| } |
| |
| static GTY(()) int compound_literal_number; |
| |
| /* Build a COMPOUND_LITERAL_EXPR. TYPE is the type given in the compound |
| literal, which may be an incomplete array type completed by the |
| initializer; INIT is a CONSTRUCTOR that initializes the compound |
| literal. */ |
| |
| tree |
| build_compound_literal (tree type, tree init) |
| { |
| /* We do not use start_decl here because we have a type, not a declarator; |
| and do not use finish_decl because the decl should be stored inside |
| the COMPOUND_LITERAL_EXPR rather than added elsewhere as a DECL_STMT. */ |
| tree decl = build_decl (VAR_DECL, NULL_TREE, type); |
| tree complit; |
| tree stmt; |
| DECL_EXTERNAL (decl) = 0; |
| TREE_PUBLIC (decl) = 0; |
| TREE_STATIC (decl) = (current_scope == global_scope); |
| DECL_CONTEXT (decl) = current_function_decl; |
| TREE_USED (decl) = 1; |
| TREE_TYPE (decl) = type; |
| TREE_READONLY (decl) = TREE_READONLY (type); |
| store_init_value (decl, init); |
| |
| if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type)) |
| { |
| int failure = complete_array_type (type, DECL_INITIAL (decl), 1); |
| if (failure) |
| abort (); |
| } |
| |
| type = TREE_TYPE (decl); |
| if (type == error_mark_node || !COMPLETE_TYPE_P (type)) |
| return error_mark_node; |
| |
| stmt = build_stmt (DECL_STMT, decl); |
| complit = build1 (COMPOUND_LITERAL_EXPR, TREE_TYPE (decl), stmt); |
| TREE_SIDE_EFFECTS (complit) = 1; |
| |
| layout_decl (decl, 0); |
| |
| if (TREE_STATIC (decl)) |
| { |
| /* This decl needs a name for the assembler output. We also need |
| a unique suffix to be added to the name. */ |
| char *name; |
| |
| ASM_FORMAT_PRIVATE_NAME (name, "__compound_literal", |
| compound_literal_number); |
| compound_literal_number++; |
| DECL_NAME (decl) = get_identifier (name); |
| DECL_DEFER_OUTPUT (decl) = 1; |
| DECL_COMDAT (decl) = 1; |
| DECL_ARTIFICIAL (decl) = 1; |
| pushdecl (decl); |
| rest_of_decl_compilation (decl, NULL, 1, 0); |
| } |
| |
| return complit; |
| } |
| |
| /* Make TYPE a complete type based on INITIAL_VALUE. |
| Return 0 if successful, 1 if INITIAL_VALUE can't be deciphered, |
| 2 if there was no information (in which case assume 1 if DO_DEFAULT). */ |
| |
| int |
| complete_array_type (tree type, tree initial_value, int do_default) |
| { |
| tree maxindex = NULL_TREE; |
| int value = 0; |
| |
| if (initial_value) |
| { |
| /* Note MAXINDEX is really the maximum index, |
| one less than the size. */ |
| if (TREE_CODE (initial_value) == STRING_CST) |
| { |
| int eltsize |
| = int_size_in_bytes (TREE_TYPE (TREE_TYPE (initial_value))); |
| maxindex = build_int_2 ((TREE_STRING_LENGTH (initial_value) |
| / eltsize) - 1, 0); |
| } |
| else if (TREE_CODE (initial_value) == CONSTRUCTOR) |
| { |
| tree elts = CONSTRUCTOR_ELTS (initial_value); |
| maxindex = build_int_2 (-1, -1); |
| for (; elts; elts = TREE_CHAIN (elts)) |
| { |
| if (TREE_PURPOSE (elts)) |
| maxindex = TREE_PURPOSE (elts); |
| else |
| maxindex = fold (build (PLUS_EXPR, integer_type_node, |
| maxindex, integer_one_node)); |
| } |
| maxindex = copy_node (maxindex); |
| } |
| else |
| { |
| /* Make an error message unless that happened already. */ |
| if (initial_value != error_mark_node) |
| value = 1; |
| |
| /* Prevent further error messages. */ |
| maxindex = build_int_2 (0, 0); |
| } |
| } |
| |
| if (!maxindex) |
| { |
| if (do_default) |
| maxindex = build_int_2 (0, 0); |
| value = 2; |
| } |
| |
| if (maxindex) |
| { |
| TYPE_DOMAIN (type) = build_index_type (maxindex); |
| if (!TREE_TYPE (maxindex)) |
| TREE_TYPE (maxindex) = TYPE_DOMAIN (type); |
| } |
| |
| /* Lay out the type now that we can get the real answer. */ |
| |
| layout_type (type); |
| |
| return value; |
| } |
| |
| /* Determine whether TYPE is a structure with a flexible array member, |
| or a union containing such a structure (possibly recursively). */ |
| |
| static bool |
| flexible_array_type_p (tree type) |
| { |
| tree x; |
| switch (TREE_CODE (type)) |
| { |
| case RECORD_TYPE: |
| x = TYPE_FIELDS (type); |
| if (x == NULL_TREE) |
| return false; |
| while (TREE_CHAIN (x) != NULL_TREE) |
| x = TREE_CHAIN (x); |
| if (TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE |
| && TYPE_SIZE (TREE_TYPE (x)) == NULL_TREE |
| && TYPE_DOMAIN (TREE_TYPE (x)) != NULL_TREE |
| && TYPE_MAX_VALUE (TYPE_DOMAIN (TREE_TYPE (x))) == NULL_TREE) |
| return true; |
| return false; |
| case UNION_TYPE: |
| for (x = TYPE_FIELDS (type); x != NULL_TREE; x = TREE_CHAIN (x)) |
| { |
| if (flexible_array_type_p (TREE_TYPE (x))) |
| return true; |
| } |
| return false; |
| default: |
| return false; |
| } |
| } |
| |
| /* Performs sanity checks on the TYPE and WIDTH of the bit-field NAME, |
| replacing with appropriate values if they are invalid. */ |
| static void |
| check_bitfield_type_and_width (tree *type, tree *width, const char *orig_name) |
| { |
| tree type_mv; |
| unsigned int max_width; |
| unsigned HOST_WIDE_INT w; |
| const char *name = orig_name ? orig_name: _("<anonymous>"); |
| |
| /* Necessary? */ |
| STRIP_NOPS (*width); |
| |
| /* Detect and ignore out of range field width and process valid |
| field widths. */ |
| if (TREE_CODE (*width) != INTEGER_CST) |
| { |
| error ("bit-field `%s' width not an integer constant", name); |
| *width = integer_one_node; |
| } |
| else |
| { |
| constant_expression_warning (*width); |
| if (tree_int_cst_sgn (*width) < 0) |
| { |
| error ("negative width in bit-field `%s'", name); |
| *width = integer_one_node; |
| } |
| else if (integer_zerop (*width) && orig_name) |
| { |
| error ("zero width for bit-field `%s'", name); |
| *width = integer_one_node; |
| } |
| } |
| |
| /* Detect invalid bit-field type. */ |
| if (TREE_CODE (*type) != INTEGER_TYPE |
| && TREE_CODE (*type) != BOOLEAN_TYPE |
| && TREE_CODE (*type) != ENUMERAL_TYPE) |
| { |
| error ("bit-field `%s' has invalid type", name); |
| *type = unsigned_type_node; |
| } |
| |
| type_mv = TYPE_MAIN_VARIANT (*type); |
| if (pedantic |
| && type_mv != integer_type_node |
| && type_mv != unsigned_type_node |
| && type_mv != boolean_type_node) |
| pedwarn ("type of bit-field `%s' is a GCC extension", name); |
| |
| if (type_mv == boolean_type_node) |
| max_width = CHAR_TYPE_SIZE; |
| else |
| max_width = TYPE_PRECISION (*type); |
| |
| if (0 < compare_tree_int (*width, max_width)) |
| { |
| error ("width of `%s' exceeds its type", name); |
| w = max_width; |
| *width = build_int_2 (w, 0); |
| } |
| else |
| w = tree_low_cst (*width, 1); |
| |
| if (TREE_CODE (*type) == ENUMERAL_TYPE |
| && (w < min_precision (TYPE_MIN_VALUE (*type), TREE_UNSIGNED (*type)) |
| || w < min_precision (TYPE_MAX_VALUE (*type), TREE_UNSIGNED (*type)))) |
| warning ("`%s' is narrower than values of its type", name); |
| } |
| |
| /* Given declspecs and a declarator, |
| determine the name and type of the object declared |
| and construct a ..._DECL node for it. |
| (In one case we can return a ..._TYPE node instead. |
| For invalid input we sometimes return 0.) |
| |
| DECLSPECS is a chain of tree_list nodes whose value fields |
| are the storage classes and type specifiers. |
| |
| DECL_CONTEXT says which syntactic context this declaration is in: |
| NORMAL for most contexts. Make a VAR_DECL or FUNCTION_DECL or TYPE_DECL. |
| FUNCDEF for a function definition. Like NORMAL but a few different |
| error messages in each case. Return value may be zero meaning |
| this definition is too screwy to try to parse. |
| PARM for a parameter declaration (either within a function prototype |
| or before a function body). Make a PARM_DECL, or return void_type_node. |
| TYPENAME if for a typename (in a cast or sizeof). |
| Don't make a DECL node; just return the ..._TYPE node. |
| FIELD for a struct or union field; make a FIELD_DECL. |
| INITIALIZED is 1 if the decl has an initializer. |
| WIDTH is non-NULL for bit-fields, and is a pointer to an INTEGER_CST node |
| representing the width of the bit-field. |
| |
| In the TYPENAME case, DECLARATOR is really an absolute declarator. |
| It may also be so in the PARM case, for a prototype where the |
| argument type is specified but not the name. |
| |
| This function is where the complicated C meanings of `static' |
| and `extern' are interpreted. */ |
| |
| static tree |
| grokdeclarator (tree declarator, tree declspecs, |
| enum decl_context decl_context, int initialized, tree *width) |
| { |
| int specbits = 0; |
| tree spec; |
| tree type = NULL_TREE; |
| int longlong = 0; |
| int constp; |
| int restrictp; |
| int volatilep; |
| int type_quals = TYPE_UNQUALIFIED; |
| int inlinep; |
| |