Mercurial > hg > CbC > CbC_gcc
diff gcc/c-decl.c @ 70:b81903832de2
merge c-decl.c
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 21 Aug 2011 09:24:16 +0900 |
parents | 1b10fe6932e1 |
children | f26ecf70364b |
line wrap: on
line diff
--- a/gcc/c-decl.c Sun Aug 21 07:53:12 2011 +0900 +++ b/gcc/c-decl.c Sun Aug 21 09:24:16 2011 +0900 @@ -58,23 +58,23 @@ #include "hashtab.h" #include "langhooks-def.h" #include "pointer-set.h" -#include "gimple.h" #ifndef noCbC #include "cbc-tree.h" tree cbc_env; tree cbc_return_f; location_t cbc_return; #endif + #include "plugin.h" #include "c-family/c-ada-spec.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) */ +{ 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) */ /* States indicating how grokdeclarator() should handle declspecs marked with __attribute__((deprecated)). An object declared as @@ -196,20 +196,20 @@ invisible bit true. */ struct GTY((chain_next ("%h.prev"))) c_binding { - union GTY(()) { /* first so GTY desc can use decl */ + union GTY(()) { /* first so GTY desc can use decl */ tree GTY((tag ("0"))) type; /* the type in this scope */ struct c_label_vars * GTY((tag ("1"))) label; /* for warnings */ } GTY((desc ("TREE_CODE (%0.decl) == LABEL_DECL"))) u; - tree decl; /* the decl bound */ - tree id; /* the identifier it's bound to */ - struct c_binding *prev; /* the previous decl in this scope */ - struct c_binding *shadowed; /* the innermost decl shadowed by this one */ + tree decl; /* the decl bound */ + tree id; /* the identifier it's bound to */ + struct c_binding *prev; /* the previous decl in this scope */ + struct c_binding *shadowed; /* the innermost decl shadowed by this one */ unsigned int depth : 28; /* depth of this scope */ BOOL_BITFIELD invisible : 1; /* normal lookup should ignore this binding */ BOOL_BITFIELD nested : 1; /* do not set DECL_CONTEXT when popping */ BOOL_BITFIELD inner_comp : 1; /* incomplete array completed in inner scope */ - BOOL_BITFIELD in_struct : 1; /* currently defined as struct field */ - location_t locus; /* location for nested bindings */ + BOOL_BITFIELD in_struct : 1; /* currently defined as struct field */ + location_t locus; /* location for nested bindings */ }; #define B_IN_SCOPE(b1, b2) ((b1)->depth == (b2)->depth) #define B_IN_CURRENT_SCOPE(b) ((b)->depth == current_scope->depth) @@ -252,7 +252,7 @@ chain_next ("TREE_CODE (&%h.generic) == INTEGER_TYPE ? (union lang_tree_node *) TYPE_NEXT_VARIANT (&%h.generic) : ((union lang_tree_node *) TREE_CHAIN (&%h.generic))"))) lang_tree_node { union tree_node GTY ((tag ("0"), - desc ("tree_node_structure (&%h)"))) + desc ("tree_node_structure (&%h)"))) generic; struct lang_identifier GTY ((tag ("1"))) identifier; }; @@ -448,25 +448,25 @@ static GTY((deletable)) struct c_binding *binding_freelist; /* 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) \ - BLOCK_CHAIN (s_->list##_last) = d_; \ - else \ - s_->list = d_; \ - s_->list##_last = d_; \ +#define SCOPE_LIST_APPEND(scope, list, decl) do { \ + struct c_scope *s_ = (scope); \ + tree d_ = (decl); \ + if (s_->list##_last) \ + BLOCK_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) \ - BLOCK_CHAIN (t_->to##_last) = f_->from; \ - else \ - t_->to = f_->from; \ - t_->to##_last = f_->from##_last; \ +#define SCOPE_LIST_CONCAT(tscope, to, fscope, from) do { \ + struct c_scope *t_ = (tscope); \ + struct c_scope *f_ = (fscope); \ + if (t_->to##_last) \ + BLOCK_CHAIN (t_->to##_last) = f_->from; \ + else \ + t_->to = f_->from; \ + t_->to##_last = f_->from##_last; \ } while (0) /* A c_inline_static structure stores details of a static identifier @@ -537,9 +537,9 @@ static tree lookup_name_in_scope (tree, struct c_scope *); static tree c_make_fname_decl (location_t, tree, int); static tree grokdeclarator (const struct c_declarator *, - struct c_declspecs *, - enum decl_context, bool, tree *, tree *, tree *, - bool *, enum deprecated_states); + struct c_declspecs *, + enum decl_context, bool, tree *, tree *, tree *, + bool *, enum deprecated_states); static tree grokparms (struct c_arg_info *, bool); static void layout_array_type (tree); @@ -555,7 +555,7 @@ if (CAN_HAVE_LOCATION_P (t) && code != LABEL_EXPR) { if (!EXPR_HAS_LOCATION (t)) - SET_EXPR_LOCATION (t, input_location); + SET_EXPR_LOCATION (t, input_location); } if (code == LABEL_EXPR || code == CASE_LABEL_EXPR) @@ -605,7 +605,7 @@ tree rid = ridpointers[C_RID_CODE (node)]; indent_to (file, indent + 4); fprintf (file, "rid " HOST_PTR_PRINTF " \"%s\"", - (void *) rid, IDENTIFIER_POINTER (rid)); + (void *) rid, IDENTIFIER_POINTER (rid)); } } @@ -694,12 +694,12 @@ labels, and add the LABEL_VARS value. */ static void bind_label (tree name, tree label, struct c_scope *scope, - struct c_label_vars *label_vars) + struct c_label_vars *label_vars) { struct c_binding *b; bind (name, label, scope, /*invisible=*/false, /*nested=*/false, - UNKNOWN_LOCATION); + UNKNOWN_LOCATION); scope->has_label_bindings = true; @@ -719,17 +719,17 @@ { tree type = TREE_TYPE (decl); if (type != error_mark_node - && TREE_CODE (type) == ARRAY_TYPE - && !DECL_EXTERNAL (decl) - && TYPE_DOMAIN (type) == 0) - { - warning_at (DECL_SOURCE_LOCATION (decl), - 0, "array %q+D assumed to have one element", decl); - - complete_array_type (&TREE_TYPE (decl), NULL_TREE, true); - - layout_decl (decl, 0); - } + && TREE_CODE (type) == ARRAY_TYPE + && !DECL_EXTERNAL (decl) + && TYPE_DOMAIN (type) == 0) + { + warning_at (DECL_SOURCE_LOCATION (decl), + 0, "array %q+D assumed to have one element", decl); + + complete_array_type (&TREE_TYPE (decl), NULL_TREE, true); + + layout_decl (decl, 0); + } } } @@ -739,7 +739,7 @@ void record_inline_static (location_t loc, tree func, tree decl, - enum c_inline_static_type type) + enum c_inline_static_type type) { struct c_inline_static *csi = ggc_alloc_c_inline_static (); csi->location = loc; @@ -761,21 +761,21 @@ for (csi = c_inline_statics; csi; csi = csi->next) { if (DECL_EXTERNAL (csi->function)) - switch (csi->type) - { - case csi_internal: - pedwarn (csi->location, 0, - "%qD is static but used in inline function %qD " - "which is not static", csi->static_decl, csi->function); - break; - case csi_modifiable: - pedwarn (csi->location, 0, - "%q+D is static but declared in inline function %qD " - "which is not static", csi->static_decl, csi->function); - break; - default: - gcc_unreachable (); - } + switch (csi->type) + { + case csi_internal: + pedwarn (csi->location, 0, + "%qD is static but used in inline function %qD " + "which is not static", csi->static_decl, csi->function); + break; + case csi_modifiable: + pedwarn (csi->location, 0, + "%q+D is static but declared in inline function %qD " + "which is not static", csi->static_decl, csi->function); + break; + default: + gcc_unreachable (); + } } c_inline_statics = NULL; } @@ -809,8 +809,8 @@ if (p->scope != scope) { /* This label or goto is defined in some other scope, or it is a - label which is not yet defined. There is nothing to - update. */ + label which is not yet defined. There is nothing to + update. */ return false; } @@ -844,11 +844,11 @@ scope = scope->outer) { for (b = scope->bindings; b; b = b->prev) - objc_volatilize_decl (b->decl); + objc_volatilize_decl (b->decl); /* Do not climb up past the current function. */ if (scope->function_body) - break; + break; } } @@ -858,8 +858,8 @@ global_bindings_p (void) { return (current_scope == file_scope && !c_override_global_bindings_to_false - ? -1 - : 0); + ? -1 + : 0); } void @@ -906,15 +906,15 @@ 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. */ + 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; @@ -926,39 +926,39 @@ /* The FLOAT_CONST_DECIMAL64 pragma applies to nested scopes. */ if (current_scope->outer) - current_scope->float_const_decimal64 - = current_scope->outer->float_const_decimal64; + current_scope->float_const_decimal64 + = current_scope->outer->float_const_decimal64; else - current_scope->float_const_decimal64 = false; + current_scope->float_const_decimal64 = false; } else { struct c_scope *scope; if (scope_freelist) - { - scope = scope_freelist; - scope_freelist = scope->outer; - } + { + scope = scope_freelist; + scope_freelist = scope->outer; + } else - scope = ggc_alloc_cleared_c_scope (); + scope = ggc_alloc_cleared_c_scope (); /* The FLOAT_CONST_DECIMAL64 pragma applies to nested scopes. */ if (current_scope) - scope->float_const_decimal64 = current_scope->float_const_decimal64; + scope->float_const_decimal64 = current_scope->float_const_decimal64; else - scope->float_const_decimal64 = false; + scope->float_const_decimal64 = false; scope->keep = keep_next_level_flag; scope->outer = current_scope; - scope->depth = current_scope ? (current_scope->depth + 1) : 0; + scope->depth = current_scope ? (current_scope->depth + 1) : 0; /* Check for scope depth overflow. Unlikely (2^28 == 268,435,456) but - possible. */ + possible. */ if (current_scope && scope->depth == 0) - { - scope->depth--; - sorry ("GCC supports only %u nested scopes", scope->depth); - } + { + scope->depth--; + sorry ("GCC supports only %u nested scopes", scope->depth); + } current_scope = scope; keep_next_level_flag = false; @@ -1027,7 +1027,7 @@ /* Don't search beyond the current function. */ if (s == current_function_scope) - break; + break; s = s->outer; } @@ -1071,7 +1071,7 @@ /* In each subblock, record that this is its superior. */ for (p = scope->blocks; p; p = BLOCK_CHAIN (p)) - BLOCK_SUPERCONTEXT (p) = block; + BLOCK_SUPERCONTEXT (p) = block; BLOCK_VARS (block) = 0; } @@ -1114,6 +1114,7 @@ } else warn_for_unused_label (p); + /* Labels go in BLOCK_VARS. */ DECL_CHAIN (p) = BLOCK_VARS (block); BLOCK_VARS (block) = p; @@ -1212,7 +1213,6 @@ DECL_EXTERNAL decl for debug info generation. */ tree extp = copy_node (p); - DECL_EXTERNAL (extp) = 1; TREE_STATIC (extp) = 0; TREE_PUBLIC (extp) = 1; @@ -1241,7 +1241,6 @@ set_type_context (TREE_TYPE (p), context); } - /* Fall through. */ /* Parameters go in DECL_ARGUMENTS, not BLOCK_VARS, and have already been put there by store_parm_decls. Unused- @@ -1276,12 +1275,12 @@ else if (scope->outer) { if (block) - SCOPE_LIST_APPEND (scope->outer, blocks, 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. */ + 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); + SCOPE_LIST_CONCAT (scope->outer, blocks, scope, blocks); } /* Pop the current scope, and free the structure for reuse. */ @@ -1311,7 +1310,7 @@ for (decl = visible_builtins; decl; decl = DECL_CHAIN (decl)) bind (DECL_NAME (decl), decl, file_scope, - /*invisible=*/false, /*nested=*/true, DECL_SOURCE_LOCATION (decl)); + /*invisible=*/false, /*nested=*/true, DECL_SOURCE_LOCATION (decl)); } void @@ -1356,7 +1355,7 @@ struct c_binding *b; if (!scope->has_label_bindings) - continue; + continue; for (b = scope->bindings; b != NULL; b = b->prev) { @@ -1389,7 +1388,7 @@ struct c_binding *b; if (!scope->has_label_bindings) - continue; + continue; for (b = scope->bindings; b != NULL; b = b->prev) { @@ -1449,7 +1448,7 @@ tagged type. */ TYPE_STUB_DECL (type) = pushdecl (build_decl (loc, - TYPE_DECL, NULL_TREE, type)); + TYPE_DECL, NULL_TREE, type)); /* An approximation for now, so we can tell this is a function-scope tag. This will be updated in pop_scope. */ @@ -1460,20 +1459,20 @@ struct c_binding *b = I_SYMBOL_BINDING (name); if (b != NULL - && b->decl != NULL_TREE - && TREE_CODE (b->decl) == TYPE_DECL - && (B_IN_CURRENT_SCOPE (b) - || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b))) - && (TYPE_MAIN_VARIANT (TREE_TYPE (b->decl)) - != TYPE_MAIN_VARIANT (type))) - { - warning_at (loc, OPT_Wc___compat, - ("using %qD as both a typedef and a tag is " - "invalid in C++"), - b->decl); - if (b->locus != UNKNOWN_LOCATION) - inform (b->locus, "originally defined here"); - } + && b->decl != NULL_TREE + && TREE_CODE (b->decl) == TYPE_DECL + && (B_IN_CURRENT_SCOPE (b) + || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b))) + && (TYPE_MAIN_VARIANT (TREE_TYPE (b->decl)) + != TYPE_MAIN_VARIANT (type))) + { + warning_at (loc, OPT_Wc___compat, + ("using %qD as both a typedef and a tag is " + "invalid in C++"), + b->decl); + if (b->locus != UNKNOWN_LOCATION) + inform (b->locus, "originally defined here"); + } } } @@ -1502,12 +1501,12 @@ while (oldargs || newargs) { if (!oldargs - || !newargs - || !TREE_VALUE (oldargs) - || !TREE_VALUE (newargs) - || TYPE_MODE (TREE_VALUE (oldargs)) - != TYPE_MODE (TREE_VALUE (newargs))) - return 0; + || !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); @@ -1522,7 +1521,7 @@ diagnostics. */ static void diagnose_arglist_conflict (tree newdecl, tree olddecl, - tree newtype, tree oldtype) + tree newtype, tree oldtype) { tree t; @@ -1540,19 +1539,19 @@ tree type = TREE_VALUE (t); if (TREE_CHAIN (t) == 0 - && TYPE_MAIN_VARIANT (type) != void_type_node) - { - inform (input_location, "a parameter list with an ellipsis can%'t match " - "an empty parameter name list declaration"); - break; - } + && TYPE_MAIN_VARIANT (type) != void_type_node) + { + inform (input_location, "a parameter list with an ellipsis can%'t match " + "an empty parameter name list declaration"); + break; + } if (c_type_promotes_to (type) != type) - { - inform (input_location, "an argument type that has a default promotion can%'t match " - "an empty parameter name list declaration"); - break; - } + { + inform (input_location, "an argument type that has a default promotion can%'t match " + "an empty parameter name list declaration"); + break; + } } } @@ -1578,38 +1577,38 @@ tree newargtype = TREE_VALUE (newargs); if (oldargtype == error_mark_node || newargtype == error_mark_node) - return false; + return false; oldargtype = TYPE_MAIN_VARIANT (oldargtype); newargtype = TYPE_MAIN_VARIANT (newargtype); if (END_OF_ARGLIST (oldargtype) && END_OF_ARGLIST (newargtype)) - break; + break; /* Reaching the end of just one list means the two decls don't - agree on the number of arguments. */ + agree on the number of arguments. */ if (END_OF_ARGLIST (oldargtype)) - { - error ("prototype for %q+D declares more arguments " - "than previous old-style definition", newdecl); - return false; - } + { + error ("prototype for %q+D declares more arguments " + "than previous old-style definition", newdecl); + return false; + } else if (END_OF_ARGLIST (newargtype)) - { - error ("prototype for %q+D declares fewer arguments " - "than previous old-style definition", newdecl); - return false; - } + { + error ("prototype for %q+D declares fewer arguments " + "than previous old-style definition", newdecl); + return false; + } /* Type for passing arg must be consistent with that declared - for the arg. */ + for the arg. */ else if (!comptypes (oldargtype, newargtype)) - { - error ("prototype for %q+D declares argument %d" - " with incompatible type", - newdecl, i); - return false; - } + { + error ("prototype for %q+D declares argument %d" + " with incompatible type", + newdecl, i); + return false; + } oldargs = TREE_CHAIN (oldargs); newargs = TREE_CHAIN (newargs); @@ -1619,7 +1618,7 @@ /* If we get here, no errors were found, but do issue a warning for this poor-style construct. */ warning (0, "prototype for %q+D follows non-prototype definition", - newdecl); + newdecl); return true; #undef END_OF_ARGLIST } @@ -1650,7 +1649,7 @@ static bool diagnose_mismatched_decls (tree newdecl, tree olddecl, - tree *newtypep, tree *oldtypep) + tree *newtypep, tree *oldtypep) { tree newtype, oldtype; bool pedwarned = false; @@ -1658,7 +1657,7 @@ bool retval = true; #define DECL_EXTERN_INLINE(DECL) (DECL_DECLARED_INLINE_P (DECL) \ - && DECL_EXTERNAL (DECL)) + && DECL_EXTERNAL (DECL)) /* If we have error_mark_node for either decl or type, just discard the previous decl - we're in an error cascade already. */ @@ -1674,18 +1673,18 @@ if (TREE_CODE (olddecl) != TREE_CODE (newdecl)) { if (!(TREE_CODE (olddecl) == FUNCTION_DECL - && DECL_BUILT_IN (olddecl) - && !C_DECL_DECLARED_BUILTIN (olddecl))) - { - error ("%q+D redeclared as different kind of symbol", newdecl); - locate_old_decl (olddecl); - } + && DECL_BUILT_IN (olddecl) + && !C_DECL_DECLARED_BUILTIN (olddecl))) + { + error ("%q+D redeclared as different kind of symbol", newdecl); + locate_old_decl (olddecl); + } else if (TREE_PUBLIC (newdecl)) - warning (0, "built-in function %q+D declared as non-function", - newdecl); + warning (0, "built-in function %q+D declared as non-function", + newdecl); else - warning (OPT_Wshadow, "declaration of %q+D shadows " - "a built-in function", newdecl); + warning (OPT_Wshadow, "declaration of %q+D shadows " + "a built-in function", newdecl); return false; } @@ -1701,98 +1700,98 @@ if (!comptypes (oldtype, newtype)) { if (TREE_CODE (olddecl) == FUNCTION_DECL - && DECL_BUILT_IN (olddecl) && !C_DECL_DECLARED_BUILTIN (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)) - *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 (0, "conflicting types for built-in function %q+D", - newdecl); - return false; - } - } + && DECL_BUILT_IN (olddecl) && !C_DECL_DECLARED_BUILTIN (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)) + *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 (0, "conflicting types for built-in function %q+D", + newdecl); + return false; + } + } else if (TREE_CODE (olddecl) == FUNCTION_DECL - && DECL_IS_BUILTIN (olddecl)) - { - /* 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; - } + && DECL_IS_BUILTIN (olddecl)) + { + /* 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. */ + 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) && !DECL_INITIAL (olddecl)) - { - pedwarned = pedwarn (input_location, 0, - "conflicting types for %q+D", newdecl); - /* Make sure we keep void as the return type. */ - TREE_TYPE (newdecl) = *newtypep = newtype = oldtype; - C_FUNCTION_IMPLICIT_INT (newdecl) = 0; - } + && TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == void_type_node + && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == integer_type_node + && C_FUNCTION_IMPLICIT_INT (newdecl) && !DECL_INITIAL (olddecl)) + { + pedwarned = pedwarn (input_location, 0, + "conflicting types for %q+D", newdecl); + /* Make sure we keep void as the return type. */ + TREE_TYPE (newdecl) = *newtypep = newtype = oldtype; + C_FUNCTION_IMPLICIT_INT (newdecl) = 0; + } /* Permit void foo (...) to match an earlier call to foo (...) with - no declared type (thus, implicitly int). */ + no declared type (thus, implicitly int). */ else if (TREE_CODE (newdecl) == FUNCTION_DECL - && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == void_type_node - && TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == integer_type_node - && C_DECL_IMPLICIT (olddecl) && !DECL_INITIAL (olddecl)) - { - pedwarned = pedwarn (input_location, 0, - "conflicting types for %q+D", newdecl); - /* Make sure we keep void as the return type. */ - TREE_TYPE (olddecl) = *oldtypep = oldtype = newtype; - } + && TYPE_MAIN_VARIANT (TREE_TYPE (newtype)) == void_type_node + && TYPE_MAIN_VARIANT (TREE_TYPE (oldtype)) == integer_type_node + && C_DECL_IMPLICIT (olddecl) && !DECL_INITIAL (olddecl)) + { + pedwarned = pedwarn (input_location, 0, + "conflicting types for %q+D", newdecl); + /* Make sure we keep void as the return type. */ + TREE_TYPE (olddecl) = *oldtypep = oldtype = newtype; + } else - { - int new_quals = TYPE_QUALS (newtype); - int old_quals = TYPE_QUALS (oldtype); - - if (new_quals != old_quals) - { - addr_space_t new_addr = DECODE_QUAL_ADDR_SPACE (new_quals); - addr_space_t old_addr = DECODE_QUAL_ADDR_SPACE (old_quals); - if (new_addr != old_addr) - { - if (ADDR_SPACE_GENERIC_P (new_addr)) - error ("conflicting named address spaces (generic vs %s) " - "for %q+D", - c_addr_space_name (old_addr), newdecl); - else if (ADDR_SPACE_GENERIC_P (old_addr)) - error ("conflicting named address spaces (%s vs generic) " - "for %q+D", - c_addr_space_name (new_addr), newdecl); - else - error ("conflicting named address spaces (%s vs %s) " - "for %q+D", - c_addr_space_name (new_addr), - c_addr_space_name (old_addr), - newdecl); - } - - if (CLEAR_QUAL_ADDR_SPACE (new_quals) - != CLEAR_QUAL_ADDR_SPACE (old_quals)) - error ("conflicting type qualifiers for %q+D", newdecl); - } - else - error ("conflicting types for %q+D", newdecl); - diagnose_arglist_conflict (newdecl, olddecl, newtype, oldtype); - locate_old_decl (olddecl); - return false; - } + { + int new_quals = TYPE_QUALS (newtype); + int old_quals = TYPE_QUALS (oldtype); + + if (new_quals != old_quals) + { + addr_space_t new_addr = DECODE_QUAL_ADDR_SPACE (new_quals); + addr_space_t old_addr = DECODE_QUAL_ADDR_SPACE (old_quals); + if (new_addr != old_addr) + { + if (ADDR_SPACE_GENERIC_P (new_addr)) + error ("conflicting named address spaces (generic vs %s) " + "for %q+D", + c_addr_space_name (old_addr), newdecl); + else if (ADDR_SPACE_GENERIC_P (old_addr)) + error ("conflicting named address spaces (%s vs generic) " + "for %q+D", + c_addr_space_name (new_addr), newdecl); + else + error ("conflicting named address spaces (%s vs %s) " + "for %q+D", + c_addr_space_name (new_addr), + c_addr_space_name (old_addr), + newdecl); + } + + if (CLEAR_QUAL_ADDR_SPACE (new_quals) + != CLEAR_QUAL_ADDR_SPACE (old_quals)) + error ("conflicting type qualifiers for %q+D", newdecl); + } + else + error ("conflicting types for %q+D", newdecl); + diagnose_arglist_conflict (newdecl, olddecl, newtype, oldtype); + locate_old_decl (olddecl); + return false; + } } /* Redeclaration of a type is a constraint violation (6.7.2.3p1), @@ -1816,10 +1815,10 @@ } if (DECL_IN_SYSTEM_HEADER (newdecl) - || DECL_IN_SYSTEM_HEADER (olddecl) - || TREE_NO_WARNING (newdecl) - || TREE_NO_WARNING (olddecl)) - return true; /* Allow OLDDECL to continue in use. */ + || DECL_IN_SYSTEM_HEADER (olddecl) + || TREE_NO_WARNING (newdecl) + || TREE_NO_WARNING (olddecl)) + return true; /* Allow OLDDECL to continue in use. */ if (pedantic && !flag_isoc1x) { @@ -1852,9 +1851,9 @@ 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. */ + 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_DECLARED_BUILTIN (olddecl) && (!TREE_PUBLIC (newdecl) @@ -1868,33 +1867,33 @@ } if (DECL_INITIAL (newdecl)) - { - if (DECL_INITIAL (olddecl)) - { - /* If both decls are in the same TU and the new declaration - isn't overriding an extern inline reject the new decl. - In c99, no overriding is allowed in the same translation - unit. */ - if ((!DECL_EXTERN_INLINE (olddecl) - || DECL_EXTERN_INLINE (newdecl) - || (!flag_gnu89_inline - && (!DECL_DECLARED_INLINE_P (olddecl) - || !lookup_attribute ("gnu_inline", - DECL_ATTRIBUTES (olddecl))) - && (!DECL_DECLARED_INLINE_P (newdecl) - || !lookup_attribute ("gnu_inline", - DECL_ATTRIBUTES (newdecl)))) - ) - && same_translation_unit_p (newdecl, olddecl)) - { - error ("redefinition of %q+D", newdecl); - locate_old_decl (olddecl); - return false; - } - } - } + { + if (DECL_INITIAL (olddecl)) + { + /* If both decls are in the same TU and the new declaration + isn't overriding an extern inline reject the new decl. + In c99, no overriding is allowed in the same translation + unit. */ + if ((!DECL_EXTERN_INLINE (olddecl) + || DECL_EXTERN_INLINE (newdecl) + || (!flag_gnu89_inline + && (!DECL_DECLARED_INLINE_P (olddecl) + || !lookup_attribute ("gnu_inline", + DECL_ATTRIBUTES (olddecl))) + && (!DECL_DECLARED_INLINE_P (newdecl) + || !lookup_attribute ("gnu_inline", + DECL_ATTRIBUTES (newdecl)))) + ) + && same_translation_unit_p (newdecl, olddecl)) + { + error ("redefinition of %q+D", newdecl); + locate_old_decl (olddecl); + return false; + } + } + } /* If we have a prototype after an old-style function definition, - the argument types must be checked specially. */ + the argument types must be checked specially. */ else if (DECL_INITIAL (olddecl) && !prototype_p (oldtype) && prototype_p (newtype) && TYPE_ACTUAL_ARG_TYPES (oldtype) @@ -1904,172 +1903,172 @@ return false; } /* A non-static declaration (even an "extern") followed by a - static declaration is undefined behavior per C99 6.2.2p3-5,7. - The same is true for a static forward declaration at block - scope followed by a non-static declaration/definition at file - scope. Static followed by non-static at the same scope is - not undefined behavior, and 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), but - we do diagnose it if -Wtraditional. */ + static declaration is undefined behavior per C99 6.2.2p3-5,7. + The same is true for a static forward declaration at block + scope followed by a non-static declaration/definition at file + scope. Static followed by non-static at the same scope is + not undefined behavior, and 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), but + we do diagnose it if -Wtraditional. */ if (TREE_PUBLIC (olddecl) && !TREE_PUBLIC (newdecl)) - { - /* Two exceptions to the rule. If olddecl is an extern - inline, or a predeclared function that isn't actually - built in, newdecl silently overrides olddecl. The latter - occur only in Objective C; see also above. (FIXME: Make - Objective C use normal builtins.) */ - if (!DECL_IS_BUILTIN (olddecl) - && !DECL_EXTERN_INLINE (olddecl)) - { - error ("static declaration of %q+D follows " - "non-static declaration", newdecl); - locate_old_decl (olddecl); - } - return false; - } + { + /* Two exceptions to the rule. If olddecl is an extern + inline, or a predeclared function that isn't actually + built in, newdecl silently overrides olddecl. The latter + occur only in Objective C; see also above. (FIXME: Make + Objective C use normal builtins.) */ + if (!DECL_IS_BUILTIN (olddecl) + && !DECL_EXTERN_INLINE (olddecl)) + { + error ("static declaration of %q+D follows " + "non-static declaration", newdecl); + locate_old_decl (olddecl); + } + return false; + } else if (TREE_PUBLIC (newdecl) && !TREE_PUBLIC (olddecl)) - { - if (DECL_CONTEXT (olddecl)) - { - error ("non-static declaration of %q+D follows " - "static declaration", newdecl); - locate_old_decl (olddecl); - return false; - } - else if (warn_traditional) - { - warned |= warning (OPT_Wtraditional, - "non-static declaration of %q+D " - "follows static declaration", newdecl); - } - } + { + if (DECL_CONTEXT (olddecl)) + { + error ("non-static declaration of %q+D follows " + "static declaration", newdecl); + locate_old_decl (olddecl); + return false; + } + else if (warn_traditional) + { + warned |= warning (OPT_Wtraditional, + "non-static declaration of %q+D " + "follows static declaration", newdecl); + } + } /* Make sure gnu_inline attribute is either not present, or - present on all inline decls. */ + present on all inline decls. */ if (DECL_DECLARED_INLINE_P (olddecl) - && DECL_DECLARED_INLINE_P (newdecl)) - { - bool newa = lookup_attribute ("gnu_inline", - DECL_ATTRIBUTES (newdecl)) != NULL; - bool olda = lookup_attribute ("gnu_inline", - DECL_ATTRIBUTES (olddecl)) != NULL; - if (newa != olda) - { - error_at (input_location, "%<gnu_inline%> attribute present on %q+D", - newa ? newdecl : olddecl); - error_at (DECL_SOURCE_LOCATION (newa ? olddecl : newdecl), - "but not here"); - } - } + && DECL_DECLARED_INLINE_P (newdecl)) + { + bool newa = lookup_attribute ("gnu_inline", + DECL_ATTRIBUTES (newdecl)) != NULL; + bool olda = lookup_attribute ("gnu_inline", + DECL_ATTRIBUTES (olddecl)) != NULL; + if (newa != olda) + { + error_at (input_location, "%<gnu_inline%> attribute present on %q+D", + newa ? newdecl : olddecl); + error_at (DECL_SOURCE_LOCATION (newa ? olddecl : newdecl), + "but not here"); + } + } } else if (TREE_CODE (newdecl) == VAR_DECL) { /* Only variables can be thread-local, and all declarations must - agree on this property. */ + agree on this property. */ if (C_DECL_THREADPRIVATE_P (olddecl) && !DECL_THREAD_LOCAL_P (newdecl)) - { - /* Nothing to check. Since OLDDECL is marked threadprivate - and NEWDECL does not have a thread-local attribute, we - will merge the threadprivate attribute into NEWDECL. */ - ; - } + { + /* Nothing to check. Since OLDDECL is marked threadprivate + and NEWDECL does not have a thread-local attribute, we + will merge the threadprivate attribute into NEWDECL. */ + ; + } else if (DECL_THREAD_LOCAL_P (newdecl) != DECL_THREAD_LOCAL_P (olddecl)) - { - if (DECL_THREAD_LOCAL_P (newdecl)) - error ("thread-local declaration of %q+D follows " - "non-thread-local declaration", newdecl); - else - error ("non-thread-local declaration of %q+D follows " - "thread-local declaration", newdecl); - - locate_old_decl (olddecl); - return false; - } + { + if (DECL_THREAD_LOCAL_P (newdecl)) + error ("thread-local declaration of %q+D follows " + "non-thread-local declaration", newdecl); + else + error ("non-thread-local declaration of %q+D follows " + "thread-local declaration", newdecl); + + locate_old_decl (olddecl); + return false; + } /* Multiple initialized definitions are not allowed (6.9p3,5). */ if (DECL_INITIAL (newdecl) && DECL_INITIAL (olddecl)) - { - error ("redefinition of %q+D", newdecl); - locate_old_decl (olddecl); - return false; - } + { + error ("redefinition of %q+D", newdecl); + locate_old_decl (olddecl); + return false; + } /* Objects declared at file scope: if the first declaration had - external linkage (even if it was an external reference) the - second must have external linkage as well, or the behavior is - undefined. If the first declaration had internal linkage, then - the second must too, or else be an external reference (in which - case the composite declaration still has internal linkage). - As for function declarations, we warn about the static-then- - extern case only for -Wtraditional. See generally 6.2.2p3-5,7. */ + external linkage (even if it was an external reference) the + second must have external linkage as well, or the behavior is + undefined. If the first declaration had internal linkage, then + the second must too, or else be an external reference (in which + case the composite declaration still has internal linkage). + As for function declarations, we warn about the static-then- + extern case only for -Wtraditional. See generally 6.2.2p3-5,7. */ if (DECL_FILE_SCOPE_P (newdecl) - && TREE_PUBLIC (newdecl) != TREE_PUBLIC (olddecl)) - { - if (DECL_EXTERNAL (newdecl)) - { - if (!DECL_FILE_SCOPE_P (olddecl)) - { - error ("extern declaration of %q+D follows " - "declaration with no linkage", newdecl); - locate_old_decl (olddecl); - return false; - } - else if (warn_traditional) - { - warned |= warning (OPT_Wtraditional, - "non-static declaration of %q+D " - "follows static declaration", newdecl); - } - } - else - { - if (TREE_PUBLIC (newdecl)) - error ("non-static declaration of %q+D follows " - "static declaration", newdecl); - else - error ("static declaration of %q+D follows " - "non-static declaration", newdecl); - - locate_old_decl (olddecl); - return false; - } - } + && TREE_PUBLIC (newdecl) != TREE_PUBLIC (olddecl)) + { + if (DECL_EXTERNAL (newdecl)) + { + if (!DECL_FILE_SCOPE_P (olddecl)) + { + error ("extern declaration of %q+D follows " + "declaration with no linkage", newdecl); + locate_old_decl (olddecl); + return false; + } + else if (warn_traditional) + { + warned |= warning (OPT_Wtraditional, + "non-static declaration of %q+D " + "follows static declaration", newdecl); + } + } + else + { + if (TREE_PUBLIC (newdecl)) + error ("non-static declaration of %q+D follows " + "static declaration", newdecl); + else + error ("static declaration of %q+D follows " + "non-static declaration", newdecl); + + locate_old_decl (olddecl); + return false; + } + } /* Two objects with the same name declared at the same block - scope must both be external references (6.7p3). */ + scope must both be external references (6.7p3). */ else if (!DECL_FILE_SCOPE_P (newdecl)) - { - if (DECL_EXTERNAL (newdecl)) - { - /* Extern with initializer at block scope, which will - already have received an error. */ - } - else if (DECL_EXTERNAL (olddecl)) - { - error ("declaration of %q+D with no linkage follows " - "extern declaration", newdecl); - locate_old_decl (olddecl); - } - else - { - error ("redeclaration of %q+D with no linkage", newdecl); - locate_old_decl (olddecl); - } - - return false; - } + { + if (DECL_EXTERNAL (newdecl)) + { + /* Extern with initializer at block scope, which will + already have received an error. */ + } + else if (DECL_EXTERNAL (olddecl)) + { + error ("declaration of %q+D with no linkage follows " + "extern declaration", newdecl); + locate_old_decl (olddecl); + } + else + { + error ("redeclaration of %q+D with no linkage", newdecl); + locate_old_decl (olddecl); + } + + return false; + } /* C++ does not permit a decl to appear multiple times at file - scope. */ + scope. */ if (warn_cxx_compat - && DECL_FILE_SCOPE_P (newdecl) - && !DECL_EXTERNAL (newdecl) - && !DECL_EXTERNAL (olddecl)) - warned |= warning_at (DECL_SOURCE_LOCATION (newdecl), - OPT_Wc___compat, - ("duplicate declaration of %qD is " - "invalid in C++"), - newdecl); + && DECL_FILE_SCOPE_P (newdecl) + && !DECL_EXTERNAL (newdecl) + && !DECL_EXTERNAL (olddecl)) + warned |= warning_at (DECL_SOURCE_LOCATION (newdecl), + OPT_Wc___compat, + ("duplicate declaration of %qD is " + "invalid in C++"), + newdecl); } /* warnings */ @@ -2079,70 +2078,70 @@ && DECL_VISIBILITY (newdecl) != DECL_VISIBILITY (olddecl)) { warned |= warning (0, "redeclaration of %q+D with different visibility " - "(old visibility preserved)", newdecl); + "(old visibility preserved)", newdecl); } 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))) - { - warned |= warning (OPT_Wattributes, - "inline declaration of %qD follows " - "declaration with attribute noinline", newdecl); - } + && lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl))) + { + warned |= warning (OPT_Wattributes, + "inline declaration of %qD follows " + "declaration with attribute noinline", newdecl); + } else if (DECL_DECLARED_INLINE_P (olddecl) - && lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl))) - { - warned |= warning (OPT_Wattributes, - "declaration of %q+D with attribute " - "noinline follows inline declaration ", newdecl); - } + && lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl))) + { + warned |= warning (OPT_Wattributes, + "declaration of %q+D with attribute " + "noinline follows inline declaration ", newdecl); + } } else /* PARM_DECL, VAR_DECL */ { /* Redeclaration of a parameter is a constraint violation (this is - not explicitly stated, but follows from C99 6.7p3 [no more than - one declaration of the same identifier with no linkage in the - same scope, except type tags] and 6.2.2p6 [parameters have no - linkage]). We must check for a forward parameter declaration, - indicated by TREE_ASM_WRITTEN on the old declaration - this is - an extension, the mandatory diagnostic for which is handled by - mark_forward_parm_decls. */ + not explicitly stated, but follows from C99 6.7p3 [no more than + one declaration of the same identifier with no linkage in the + same scope, except type tags] and 6.2.2p6 [parameters have no + linkage]). We must check for a forward parameter declaration, + indicated by TREE_ASM_WRITTEN on the old declaration - this is + an extension, the mandatory diagnostic for which is handled by + mark_forward_parm_decls. */ if (TREE_CODE (newdecl) == PARM_DECL - && (!TREE_ASM_WRITTEN (olddecl) || TREE_ASM_WRITTEN (newdecl))) - { - error ("redefinition of parameter %q+D", newdecl); - locate_old_decl (olddecl); - return false; - } + && (!TREE_ASM_WRITTEN (olddecl) || TREE_ASM_WRITTEN (newdecl))) + { + error ("redefinition of parameter %q+D", newdecl); + locate_old_decl (olddecl); + return false; + } } /* Optional warning for completely redundant decls. */ if (!warned && !pedwarned && warn_redundant_decls /* Don't warn about a function declaration followed by a - definition. */ + definition. */ && !(TREE_CODE (newdecl) == FUNCTION_DECL - && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl)) + && 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_DECLARED_BUILTIN (olddecl)) + && !DECL_BUILT_IN (newdecl) + && DECL_BUILT_IN (olddecl) + && !C_DECL_DECLARED_BUILTIN (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)) + && TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl)) /* Don't warn about a variable definition following a declaration. */ && !(TREE_CODE (newdecl) == VAR_DECL - && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl))) + && DECL_INITIAL (newdecl) && !DECL_INITIAL (olddecl))) { warned = warning (OPT_Wredundant_decls, "redundant redeclaration of %q+D", - newdecl); + newdecl); } /* Report location of previous decl/defn. */ @@ -2163,7 +2162,7 @@ merge_decls (tree newdecl, tree olddecl, tree newtype, tree oldtype) { bool new_is_definition = (TREE_CODE (newdecl) == FUNCTION_DECL - && DECL_INITIAL (newdecl) != 0); + && DECL_INITIAL (newdecl) != 0); bool new_is_prototype = (TREE_CODE (newdecl) == FUNCTION_DECL && prototype_p (TREE_TYPE (newdecl))); bool old_is_prototype = (TREE_CODE (olddecl) == FUNCTION_DECL @@ -2179,8 +2178,8 @@ struct c_binding *b, **here; for (here = ¤t_scope->bindings; *here; here = &(*here)->prev) - if ((*here)->decl == olddecl) - goto found; + if ((*here)->decl == olddecl) + goto found; gcc_unreachable (); found: @@ -2204,11 +2203,11 @@ if (!comptypes (oldtype, TREE_TYPE (newdecl))) { if (TREE_TYPE (newdecl) != error_mark_node) - layout_type (TREE_TYPE (newdecl)); + 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); + && TREE_CODE (newdecl) != TYPE_DECL + && TREE_CODE (newdecl) != CONST_DECL) + layout_decl (newdecl, 0); } else { @@ -2217,10 +2216,10 @@ DECL_SIZE_UNIT (newdecl) = DECL_SIZE_UNIT (olddecl); DECL_MODE (newdecl) = DECL_MODE (olddecl); if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl)) - { - DECL_ALIGN (newdecl) = DECL_ALIGN (olddecl); - DECL_USER_ALIGN (newdecl) |= DECL_USER_ALIGN (olddecl); - } + { + DECL_ALIGN (newdecl) = DECL_ALIGN (olddecl); + DECL_USER_ALIGN (newdecl) |= DECL_USER_ALIGN (olddecl); + } } /* Keep the old rtl since we can safely use it. */ @@ -2247,12 +2246,12 @@ && !DECL_IN_SYSTEM_HEADER (newdecl) ) DECL_SOURCE_LOCATION (newdecl) = DECL_SOURCE_LOCATION (olddecl); else if (CODE_CONTAINS_STRUCT (TREE_CODE (olddecl), TS_DECL_WITH_VIS) - && DECL_IN_SYSTEM_HEADER (newdecl) - && !DECL_IN_SYSTEM_HEADER (olddecl)) + && DECL_IN_SYSTEM_HEADER (newdecl) + && !DECL_IN_SYSTEM_HEADER (olddecl)) DECL_SOURCE_LOCATION (olddecl) = DECL_SOURCE_LOCATION (newdecl); else if ((DECL_INITIAL (newdecl) == 0 && DECL_INITIAL (olddecl) != 0) - || (old_is_prototype && !new_is_prototype - && !C_DECL_BUILTIN_PROTOTYPE (olddecl))) + || (old_is_prototype && !new_is_prototype + && !C_DECL_BUILTIN_PROTOTYPE (olddecl))) DECL_SOURCE_LOCATION (newdecl) = DECL_SOURCE_LOCATION (olddecl); /* Merge the initialization information. */ @@ -2269,52 +2268,52 @@ if (CODE_CONTAINS_STRUCT (TREE_CODE (olddecl), TS_DECL_WITH_VIS)) { /* 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. */ + 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); + DECL_SECTION_NAME (newdecl) = DECL_SECTION_NAME (olddecl); /* Copy the assembler name. - Currently, it can only be defined in the prototype. */ + Currently, it can only be defined in the prototype. */ COPY_DECL_ASSEMBLER_NAME (olddecl, newdecl); /* Use visibility of whichever declaration had it specified */ if (DECL_VISIBILITY_SPECIFIED (olddecl)) - { - DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl); - DECL_VISIBILITY_SPECIFIED (newdecl) = 1; - } + { + DECL_VISIBILITY (newdecl) = DECL_VISIBILITY (olddecl); + DECL_VISIBILITY_SPECIFIED (newdecl) = 1; + } 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); - DECL_IS_MALLOC (newdecl) |= DECL_IS_MALLOC (olddecl); - DECL_IS_OPERATOR_NEW (newdecl) |= DECL_IS_OPERATOR_NEW (olddecl); - TREE_READONLY (newdecl) |= TREE_READONLY (olddecl); - DECL_PURE_P (newdecl) |= DECL_PURE_P (olddecl); - DECL_IS_NOVOPS (newdecl) |= DECL_IS_NOVOPS (olddecl); - } + { + 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); + DECL_IS_MALLOC (newdecl) |= DECL_IS_MALLOC (olddecl); + DECL_IS_OPERATOR_NEW (newdecl) |= DECL_IS_OPERATOR_NEW (olddecl); + TREE_READONLY (newdecl) |= TREE_READONLY (olddecl); + DECL_PURE_P (newdecl) |= DECL_PURE_P (olddecl); + DECL_IS_NOVOPS (newdecl) |= DECL_IS_NOVOPS (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; - } + { + 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; + } } /* In c99, 'extern' declaration before (or after) 'inline' means this @@ -2323,10 +2322,10 @@ if (TREE_CODE (newdecl) == FUNCTION_DECL && !flag_gnu89_inline && (DECL_DECLARED_INLINE_P (newdecl) - || DECL_DECLARED_INLINE_P (olddecl)) + || DECL_DECLARED_INLINE_P (olddecl)) && (!DECL_DECLARED_INLINE_P (newdecl) - || !DECL_DECLARED_INLINE_P (olddecl) - || !DECL_EXTERNAL (olddecl)) + || !DECL_DECLARED_INLINE_P (olddecl) + || !DECL_EXTERNAL (olddecl)) && DECL_EXTERNAL (newdecl) && !lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (newdecl)) && !current_function_decl) @@ -2340,10 +2339,10 @@ /* 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); - } + { + DECL_CONTEXT (newdecl) = DECL_CONTEXT (olddecl); + DECL_COMMON (newdecl) = DECL_COMMON (olddecl); + } } else { @@ -2354,53 +2353,53 @@ 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. */ + 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)) - /* The new defn must not be inline. */ - DECL_UNINLINABLE (newdecl) = 1; + /* The new defn must not be inline. */ + 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)); - - DECL_DISREGARD_INLINE_LIMITS (newdecl) - = DECL_DISREGARD_INLINE_LIMITS (olddecl) - = (DECL_DISREGARD_INLINE_LIMITS (newdecl) - || DECL_DISREGARD_INLINE_LIMITS (olddecl)); - } + { + /* 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)); + + DECL_DISREGARD_INLINE_LIMITS (newdecl) + = DECL_DISREGARD_INLINE_LIMITS (olddecl) + = (DECL_DISREGARD_INLINE_LIMITS (newdecl) + || DECL_DISREGARD_INLINE_LIMITS (olddecl)); + } if (DECL_BUILT_IN (olddecl)) - { - /* If redeclaring a builtin function, it stays built in. - But it gets tagged as having been declared. */ - DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl); - DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl); - C_DECL_DECLARED_BUILTIN (newdecl) = 1; - if (new_is_prototype) - C_DECL_BUILTIN_PROTOTYPE (newdecl) = 0; - else - C_DECL_BUILTIN_PROTOTYPE (newdecl) - = C_DECL_BUILTIN_PROTOTYPE (olddecl); - } + { + /* If redeclaring a builtin function, it stays built in. + But it gets tagged as having been declared. */ + DECL_BUILT_IN_CLASS (newdecl) = DECL_BUILT_IN_CLASS (olddecl); + DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl); + C_DECL_DECLARED_BUILTIN (newdecl) = 1; + if (new_is_prototype) + C_DECL_BUILTIN_PROTOTYPE (newdecl) = 0; + else + C_DECL_BUILTIN_PROTOTYPE (newdecl) + = C_DECL_BUILTIN_PROTOTYPE (olddecl); + } /* Preserve function specific target and optimization options */ if (DECL_FUNCTION_SPECIFIC_TARGET (olddecl) - && !DECL_FUNCTION_SPECIFIC_TARGET (newdecl)) - DECL_FUNCTION_SPECIFIC_TARGET (newdecl) - = DECL_FUNCTION_SPECIFIC_TARGET (olddecl); + && !DECL_FUNCTION_SPECIFIC_TARGET (newdecl)) + DECL_FUNCTION_SPECIFIC_TARGET (newdecl) + = DECL_FUNCTION_SPECIFIC_TARGET (olddecl); if (DECL_FUNCTION_SPECIFIC_OPTIMIZATION (olddecl) - && !DECL_FUNCTION_SPECIFIC_OPTIMIZATION (newdecl)) - DECL_FUNCTION_SPECIFIC_OPTIMIZATION (newdecl) - = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (olddecl); + && !DECL_FUNCTION_SPECIFIC_OPTIMIZATION (newdecl)) + DECL_FUNCTION_SPECIFIC_OPTIMIZATION (newdecl) + = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (olddecl); /* Also preserve various other info from the definition. */ if (!new_is_definition) @@ -2446,8 +2445,8 @@ olddecl_arguments = DECL_ARGUMENTS (olddecl); memcpy ((char *) olddecl + sizeof (struct tree_common), - (char *) newdecl + sizeof (struct tree_common), - sizeof (struct tree_decl_common) - sizeof (struct tree_common)); + (char *) newdecl + sizeof (struct tree_common), + sizeof (struct tree_decl_common) - sizeof (struct tree_common)); switch (TREE_CODE (olddecl)) { case FUNCTION_DECL: @@ -2458,16 +2457,16 @@ case RESULT_DECL: case CONST_DECL: case TYPE_DECL: - memcpy ((char *) olddecl + sizeof (struct tree_decl_common), - (char *) newdecl + sizeof (struct tree_decl_common), - tree_code_size (TREE_CODE (olddecl)) - sizeof (struct tree_decl_common)); - break; + memcpy ((char *) olddecl + sizeof (struct tree_decl_common), + (char *) newdecl + sizeof (struct tree_decl_common), + tree_code_size (TREE_CODE (olddecl)) - sizeof (struct tree_decl_common)); + break; default: - memcpy ((char *) olddecl + sizeof (struct tree_decl_common), - (char *) newdecl + sizeof (struct tree_decl_common), - sizeof (struct tree_decl_non_common) - sizeof (struct tree_decl_common)); + memcpy ((char *) olddecl + sizeof (struct tree_decl_common), + (char *) newdecl + sizeof (struct tree_decl_common), + sizeof (struct tree_decl_non_common) - sizeof (struct tree_decl_common)); } DECL_UID (olddecl) = olddecl_uid; DECL_CONTEXT (olddecl) = olddecl_context; @@ -2480,8 +2479,8 @@ flags and attributes. */ if (DECL_RTL_SET_P (olddecl) && (TREE_CODE (olddecl) == FUNCTION_DECL - || (TREE_CODE (olddecl) == VAR_DECL - && TREE_STATIC (olddecl)))) + || (TREE_CODE (olddecl) == VAR_DECL + && TREE_STATIC (olddecl)))) make_decl_rtl (olddecl); /* If we changed a function from DECL_EXTERNAL to !DECL_EXTERNAL, @@ -2534,35 +2533,35 @@ for (b = I_SYMBOL_BINDING (DECL_NAME (new_decl)); b; b = b->shadowed) if (b->decl && b->decl != new_decl && !b->invisible) { - tree old_decl = b->decl; - - if (old_decl == error_mark_node) - { - warning (OPT_Wshadow, "declaration of %q+D shadows previous " - "non-variable", new_decl); - break; - } - else if (TREE_CODE (old_decl) == PARM_DECL) - warning (OPT_Wshadow, "declaration of %q+D shadows a parameter", - new_decl); - else if (DECL_FILE_SCOPE_P (old_decl)) - warning (OPT_Wshadow, "declaration of %q+D shadows a global " - "declaration", new_decl); - else if (TREE_CODE (old_decl) == FUNCTION_DECL - && DECL_BUILT_IN (old_decl)) - { - warning (OPT_Wshadow, "declaration of %q+D shadows " - "a built-in function", new_decl); - break; - } - else - warning (OPT_Wshadow, "declaration of %q+D shadows a previous local", - new_decl); - - warning_at (DECL_SOURCE_LOCATION (old_decl), OPT_Wshadow, - "shadowed declaration is here"); - - break; + tree old_decl = b->decl; + + if (old_decl == error_mark_node) + { + warning (OPT_Wshadow, "declaration of %q+D shadows previous " + "non-variable", new_decl); + break; + } + else if (TREE_CODE (old_decl) == PARM_DECL) + warning (OPT_Wshadow, "declaration of %q+D shadows a parameter", + new_decl); + else if (DECL_FILE_SCOPE_P (old_decl)) + warning (OPT_Wshadow, "declaration of %q+D shadows a global " + "declaration", new_decl); + else if (TREE_CODE (old_decl) == FUNCTION_DECL + && DECL_BUILT_IN (old_decl)) + { + warning (OPT_Wshadow, "declaration of %q+D shadows " + "a built-in function", new_decl); + break; + } + else + warning (OPT_Wshadow, "declaration of %q+D shadows a previous local", + new_decl); + + warning_at (DECL_SOURCE_LOCATION (old_decl), OPT_Wshadow, + "shadowed declaration is here"); + + break; } } @@ -2588,14 +2587,14 @@ unless they have initializers (which generate code). */ if (current_function_decl && ((TREE_CODE (x) != FUNCTION_DECL && TREE_CODE (x) != VAR_DECL) - || DECL_INITIAL (x) || !DECL_EXTERNAL (x))) + || DECL_INITIAL (x) || !DECL_EXTERNAL (x))) DECL_CONTEXT (x) = current_function_decl; /* Anonymous decls are just inserted in the scope. */ if (!name) { bind (name, x, scope, /*invisible=*/false, /*nested=*/false, - locus); + locus); return x; } @@ -2614,49 +2613,49 @@ tree visdecl = b->decl; tree vistype = TREE_TYPE (visdecl); if (TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE - && COMPLETE_TYPE_P (TREE_TYPE (x))) - b->inner_comp = false; + && COMPLETE_TYPE_P (TREE_TYPE (x))) + b->inner_comp = false; b_use = b; b_ext = b; /* If this is an external linkage declaration, we should check - for compatibility with the type in the external scope before - setting the type at this scope based on the visible - information only. */ + for compatibility with the type in the external scope before + setting the type at this scope based on the visible + information only. */ if (TREE_PUBLIC (x) && TREE_PUBLIC (visdecl)) - { - while (b_ext && !B_IN_EXTERNAL_SCOPE (b_ext)) - b_ext = b_ext->shadowed; - if (b_ext) - { - b_use = b_ext; - if (b_use->u.type) - TREE_TYPE (b_use->decl) = b_use->u.type; - } - } + { + while (b_ext && !B_IN_EXTERNAL_SCOPE (b_ext)) + b_ext = b_ext->shadowed; + if (b_ext) + { + b_use = b_ext; + if (b_use->u.type) + TREE_TYPE (b_use->decl) = b_use->u.type; + } + } if (duplicate_decls (x, b_use->decl)) - { - if (b_use != b) - { - /* Save the updated type in the external scope and - restore the proper type for this scope. */ - tree thistype; - if (comptypes (vistype, type)) - thistype = composite_type (vistype, type); - else - thistype = TREE_TYPE (b_use->decl); - b_use->u.type = TREE_TYPE (b_use->decl); - if (TREE_CODE (b_use->decl) == FUNCTION_DECL - && DECL_BUILT_IN (b_use->decl)) - thistype - = build_type_attribute_variant (thistype, - TYPE_ATTRIBUTES - (b_use->u.type)); - TREE_TYPE (b_use->decl) = thistype; - } - return b_use->decl; - } + { + if (b_use != b) + { + /* Save the updated type in the external scope and + restore the proper type for this scope. */ + tree thistype; + if (comptypes (vistype, type)) + thistype = composite_type (vistype, type); + else + thistype = TREE_TYPE (b_use->decl); + b_use->u.type = TREE_TYPE (b_use->decl); + if (TREE_CODE (b_use->decl) == FUNCTION_DECL + && DECL_BUILT_IN (b_use->decl)) + thistype + = build_type_attribute_variant (thistype, + TYPE_ATTRIBUTES + (b_use->u.type)); + TREE_TYPE (b_use->decl) = thistype; + } + return b_use->decl; + } else - goto skip_external_and_shadow_checks; + goto skip_external_and_shadow_checks; } /* All declarations with external linkage, and all external @@ -2678,106 +2677,106 @@ tree visdecl = 0; bool type_saved = false; if (b && !B_IN_EXTERNAL_SCOPE (b) - && (TREE_CODE (b->decl) == FUNCTION_DECL - || TREE_CODE (b->decl) == VAR_DECL) - && DECL_FILE_SCOPE_P (b->decl)) - { - visdecl = b->decl; - vistype = TREE_TYPE (visdecl); - } + && (TREE_CODE (b->decl) == FUNCTION_DECL + || TREE_CODE (b->decl) == VAR_DECL) + && DECL_FILE_SCOPE_P (b->decl)) + { + visdecl = b->decl; + vistype = TREE_TYPE (visdecl); + } if (scope != file_scope - && !DECL_IN_SYSTEM_HEADER (x)) - warning (OPT_Wnested_externs, "nested extern declaration of %qD", x); + && !DECL_IN_SYSTEM_HEADER (x)) + warning (OPT_Wnested_externs, "nested extern declaration of %qD", x); while (b && !B_IN_EXTERNAL_SCOPE (b)) - { - /* If this decl might be modified, save its type. This is - done here rather than when the decl is first bound - because the type may change after first binding, through - being completed or through attributes being added. If we - encounter multiple such decls, only the first should have - its type saved; the others will already have had their - proper types saved and the types will not have changed as - their scopes will not have been re-entered. */ - if (DECL_P (b->decl) && DECL_FILE_SCOPE_P (b->decl) && !type_saved) - { - b->u.type = TREE_TYPE (b->decl); - type_saved = true; - } - if (B_IN_FILE_SCOPE (b) - && TREE_CODE (b->decl) == VAR_DECL - && TREE_STATIC (b->decl) - && TREE_CODE (TREE_TYPE (b->decl)) == ARRAY_TYPE - && !TYPE_DOMAIN (TREE_TYPE (b->decl)) - && TREE_CODE (type) == ARRAY_TYPE - && TYPE_DOMAIN (type) - && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) - && !integer_zerop (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))) - { - /* Array type completed in inner scope, which should be - diagnosed if the completion does not have size 1 and - it does not get completed in the file scope. */ - b->inner_comp = true; - } - b = b->shadowed; - } + { + /* If this decl might be modified, save its type. This is + done here rather than when the decl is first bound + because the type may change after first binding, through + being completed or through attributes being added. If we + encounter multiple such decls, only the first should have + its type saved; the others will already have had their + proper types saved and the types will not have changed as + their scopes will not have been re-entered. */ + if (DECL_P (b->decl) && DECL_FILE_SCOPE_P (b->decl) && !type_saved) + { + b->u.type = TREE_TYPE (b->decl); + type_saved = true; + } + if (B_IN_FILE_SCOPE (b) + && TREE_CODE (b->decl) == VAR_DECL + && TREE_STATIC (b->decl) + && TREE_CODE (TREE_TYPE (b->decl)) == ARRAY_TYPE + && !TYPE_DOMAIN (TREE_TYPE (b->decl)) + && TREE_CODE (type) == ARRAY_TYPE + && TYPE_DOMAIN (type) + && TYPE_MAX_VALUE (TYPE_DOMAIN (type)) + && !integer_zerop (TYPE_MAX_VALUE (TYPE_DOMAIN (type)))) + { + /* Array type completed in inner scope, which should be + diagnosed if the completion does not have size 1 and + it does not get completed in the file scope. */ + b->inner_comp = true; + } + b = b->shadowed; + } /* If a matching external declaration has been found, set its - type to the composite of all the types of that declaration. - After the consistency checks, it will be reset to the - composite of the visible types only. */ + type to the composite of all the types of that declaration. + After the consistency checks, it will be reset to the + composite of the visible types only. */ if (b && (TREE_PUBLIC (x) || same_translation_unit_p (x, b->decl)) - && b->u.type) - TREE_TYPE (b->decl) = b->u.type; + && b->u.type) + TREE_TYPE (b->decl) = b->u.type; /* The point of the same_translation_unit_p check here is, - we want to detect a duplicate decl for a construct like - foo() { extern bar(); } ... static bar(); but not if - they are in different translation units. In any case, - the static does not go in the externals scope. */ + we want to detect a duplicate decl for a construct like + foo() { extern bar(); } ... static bar(); but not if + they are in different translation units. In any case, + the static does not go in the externals scope. */ if (b - && (TREE_PUBLIC (x) || same_translation_unit_p (x, b->decl)) - && duplicate_decls (x, b->decl)) - { - tree thistype; - if (vistype) - { - if (comptypes (vistype, type)) - thistype = composite_type (vistype, type); - else - thistype = TREE_TYPE (b->decl); - } - else - thistype = type; - b->u.type = TREE_TYPE (b->decl); - if (TREE_CODE (b->decl) == FUNCTION_DECL && DECL_BUILT_IN (b->decl)) - thistype - = build_type_attribute_variant (thistype, - TYPE_ATTRIBUTES (b->u.type)); - TREE_TYPE (b->decl) = thistype; - bind (name, b->decl, scope, /*invisible=*/false, /*nested=*/true, - locus); - return b->decl; - } + && (TREE_PUBLIC (x) || same_translation_unit_p (x, b->decl)) + && duplicate_decls (x, b->decl)) + { + tree thistype; + if (vistype) + { + if (comptypes (vistype, type)) + thistype = composite_type (vistype, type); + else + thistype = TREE_TYPE (b->decl); + } + else + thistype = type; + b->u.type = TREE_TYPE (b->decl); + if (TREE_CODE (b->decl) == FUNCTION_DECL && DECL_BUILT_IN (b->decl)) + thistype + = build_type_attribute_variant (thistype, + TYPE_ATTRIBUTES (b->u.type)); + TREE_TYPE (b->decl) = thistype; + bind (name, b->decl, scope, /*invisible=*/false, /*nested=*/true, + locus); + return b->decl; + } else if (TREE_PUBLIC (x)) - { - if (visdecl && !b && duplicate_decls (x, visdecl)) - { - /* An external declaration at block scope referring to a - visible entity with internal linkage. The composite - type will already be correct for this scope, so we - just need to fall through to make the declaration in - this scope. */ - nested = true; - x = visdecl; - } - else - { - bind (name, x, external_scope, /*invisible=*/true, - /*nested=*/false, locus); - nested = true; - } - } + { + if (visdecl && !b && duplicate_decls (x, visdecl)) + { + /* An external declaration at block scope referring to a + visible entity with internal linkage. The composite + type will already be correct for this scope, so we + just need to fall through to make the declaration in + this scope. */ + nested = true; + x = visdecl; + } + else + { + bind (name, x, external_scope, /*invisible=*/true, + /*nested=*/false, locus); + nested = true; + } + } } if (TREE_CODE (x) != PARM_DECL) @@ -2804,16 +2803,16 @@ tree element = TREE_TYPE (x); while (TREE_CODE (element) == ARRAY_TYPE) - element = TREE_TYPE (element); + 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)); + || 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)); } return x; } @@ -2837,7 +2836,7 @@ if (TREE_PUBLIC (x)) { bind (name, x, external_scope, /*invisible=*/true, /*nested=*/false, - UNKNOWN_LOCATION); + UNKNOWN_LOCATION); nested = true; } if (file_scope) @@ -2854,13 +2853,13 @@ bool warned; if (flag_isoc99) - warned = pedwarn (input_location, OPT_Wimplicit_function_declaration, - "implicit declaration of function %qE", id); + warned = pedwarn (input_location, OPT_Wimplicit_function_declaration, + "implicit declaration of function %qE", id); else - warned = warning (OPT_Wimplicit_function_declaration, - G_("implicit declaration of function %qE"), id); + warned = warning (OPT_Wimplicit_function_declaration, + G_("implicit declaration of function %qE"), id); if (olddecl && warned) - locate_old_decl (olddecl); + locate_old_decl (olddecl); } } @@ -2882,70 +2881,70 @@ for (b = I_SYMBOL_BINDING (functionid); b; b = b->shadowed) { if (B_IN_SCOPE (b, external_scope)) - { - decl = b->decl; - break; - } + { + decl = b->decl; + break; + } } if (decl) { if (decl == error_mark_node) - return decl; + return decl; /* FIXME: Objective-C has weird not-really-builtin functions - which are supposed to be visible automatically. They wind up - in the external scope because they're pushed before the file - scope gets created. Catch this here and rebind them into the - file scope. */ + which are supposed to be visible automatically. They wind up + in the external scope because they're pushed before the file + scope gets created. Catch this here and rebind them into the + file scope. */ if (!DECL_BUILT_IN (decl) && DECL_IS_BUILTIN (decl)) - { - bind (functionid, decl, file_scope, - /*invisible=*/false, /*nested=*/true, - DECL_SOURCE_LOCATION (decl)); - return decl; - } + { + bind (functionid, decl, file_scope, + /*invisible=*/false, /*nested=*/true, + DECL_SOURCE_LOCATION (decl)); + return decl; + } else - { - tree newtype = default_function_type; - if (b->u.type) - TREE_TYPE (decl) = b->u.type; - /* 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 but with the new type. */ - if (!C_DECL_IMPLICIT (decl)) - { - implicit_decl_warning (functionid, decl); - C_DECL_IMPLICIT (decl) = 1; - } - if (DECL_BUILT_IN (decl)) - { - newtype = build_type_attribute_variant (newtype, - TYPE_ATTRIBUTES - (TREE_TYPE (decl))); - if (!comptypes (newtype, TREE_TYPE (decl))) - { - warning_at (loc, 0, "incompatible implicit declaration of " - "built-in function %qD", decl); - newtype = TREE_TYPE (decl); - } - } - else - { - if (!comptypes (newtype, TREE_TYPE (decl))) - { - error_at (loc, "incompatible implicit declaration of function %qD", decl); - locate_old_decl (decl); - } - } - b->u.type = TREE_TYPE (decl); - TREE_TYPE (decl) = newtype; - bind (functionid, decl, current_scope, - /*invisible=*/false, /*nested=*/true, - DECL_SOURCE_LOCATION (decl)); - return decl; - } + { + tree newtype = default_function_type; + if (b->u.type) + TREE_TYPE (decl) = b->u.type; + /* 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 but with the new type. */ + if (!C_DECL_IMPLICIT (decl)) + { + implicit_decl_warning (functionid, decl); + C_DECL_IMPLICIT (decl) = 1; + } + if (DECL_BUILT_IN (decl)) + { + newtype = build_type_attribute_variant (newtype, + TYPE_ATTRIBUTES + (TREE_TYPE (decl))); + if (!comptypes (newtype, TREE_TYPE (decl))) + { + warning_at (loc, 0, "incompatible implicit declaration of " + "built-in function %qD", decl); + newtype = TREE_TYPE (decl); + } + } + else + { + if (!comptypes (newtype, TREE_TYPE (decl))) + { + error_at (loc, "incompatible implicit declaration of function %qD", decl); + locate_old_decl (decl); + } + } + b->u.type = TREE_TYPE (decl); + TREE_TYPE (decl) = newtype; + bind (functionid, decl, current_scope, + /*invisible=*/false, /*nested=*/true, + DECL_SOURCE_LOCATION (decl)); + return decl; + } } /* Not seen before. */ @@ -3008,11 +3007,11 @@ } /* If we are parsing old-style parameter decls, current_function_decl - will be nonnull but current_function_scope will be null. */ + will be nonnull but current_function_scope will be null. */ scope = current_function_scope ? current_function_scope : current_scope; } bind (id, error_mark_node, scope, /*invisible=*/false, /*nested=*/false, - UNKNOWN_LOCATION); + UNKNOWN_LOCATION); } /* Subroutine of lookup_label, declare_label, define_label: construct a @@ -3021,7 +3020,7 @@ static tree make_label (location_t location, tree name, bool defining, - struct c_label_vars **p_label_vars) + struct c_label_vars **p_label_vars) { tree label = build_decl (location, LABEL_DECL, name, void_type_node); struct c_label_vars *label_vars; @@ -3061,13 +3060,13 @@ using __label__. */ label = I_LABEL_DECL (name); if (label && (DECL_CONTEXT (label) == current_function_decl - || C_DECLARED_LABEL_FLAG (label))) + || 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. */ + location to point here, for better diagnostics if it + turns out not to have been defined. */ if (DECL_INITIAL (label) == NULL_TREE) - DECL_SOURCE_LOCATION (label) = input_location; + DECL_SOURCE_LOCATION (label) = input_location; return label; } @@ -3088,10 +3087,10 @@ { if (variably_modified_type_p (TREE_TYPE (decl), NULL_TREE)) error_at (goto_loc, - "jump into scope of identifier with variably modified type"); + "jump into scope of identifier with variably modified type"); else warning_at (goto_loc, OPT_Wjump_misses_init, - "jump skips variable initialization"); + "jump skips variable initialization"); inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label); inform (DECL_SOURCE_LOCATION (decl), "%qD declared here", decl); } @@ -3214,7 +3213,7 @@ } /* We also need to warn about decls defined in any scopes - between the scope of the label and the scope of the goto. */ + between the scope of the label and the scope of the goto. */ for (scope = label_vars->label_bindings.scope; scope != g->goto_bindings.scope; scope = scope->outer) @@ -3235,11 +3234,11 @@ } if (g->goto_bindings.stmt_exprs > 0) - { - error_at (g->loc, "jump into statement expression"); - inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", - label); - } + { + error_at (g->loc, "jump into statement expression"); + inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", + label); + } } /* Now that the label is defined, we will issue warnings about @@ -3263,9 +3262,9 @@ if (label && ((DECL_CONTEXT (label) == current_function_decl - && DECL_INITIAL (label) != 0) - || (DECL_CONTEXT (label) != current_function_decl - && C_DECLARED_LABEL_FLAG (label)))) + && DECL_INITIAL (label) != 0) + || (DECL_CONTEXT (label) != current_function_decl + && C_DECLARED_LABEL_FLAG (label)))) { error_at (location, "duplicate label %qD", label); locate_old_decl (label); @@ -3276,13 +3275,13 @@ struct c_label_vars *label_vars = I_LABEL_BINDING (name)->u.label; /* The label has been used or declared already in this function, - but not defined. Update its location to point to this - definition. */ + but not defined. Update its location to point to this + definition. */ DECL_SOURCE_LOCATION (label) = location; set_spot_bindings (&label_vars->label_bindings, true); /* Issue warnings as required about any goto statements from - earlier in the function. */ + earlier in the function. */ check_earlier_gotos (label, label_vars); } else @@ -3298,8 +3297,8 @@ if (!in_system_header && lookup_name (name)) warning_at (location, OPT_Wtraditional, - "traditional C lacks a separate namespace " - "for labels, identifier %qE conflicts", name); + "traditional C lacks a separate namespace " + "for labels, identifier %qE conflicts", name); /* Mark label as having been defined. */ DECL_INITIAL (label) = error_mark_node; @@ -3333,7 +3332,7 @@ bool c_check_switch_jump_warnings (struct c_spot_bindings *switch_bindings, - location_t switch_loc, location_t case_loc) + location_t switch_loc, location_t case_loc) { bool saw_error; struct c_scope *scope; @@ -3351,24 +3350,24 @@ continue; for (b = scope->bindings; b != NULL; b = b->prev) - { - if (decl_jump_unsafe (b->decl)) - { - if (variably_modified_type_p (TREE_TYPE (b->decl), NULL_TREE)) - { - saw_error = true; - error_at (case_loc, - ("switch jumps into scope of identifier with " - "variably modified type")); - } - else - warning_at (case_loc, OPT_Wjump_misses_init, - "switch jumps over variable initialization"); - inform (switch_loc, "switch starts here"); - inform (DECL_SOURCE_LOCATION (b->decl), "%qD declared here", - b->decl); - } - } + { + if (decl_jump_unsafe (b->decl)) + { + if (variably_modified_type_p (TREE_TYPE (b->decl), NULL_TREE)) + { + saw_error = true; + error_at (case_loc, + ("switch jumps into scope of identifier with " + "variably modified type")); + } + else + warning_at (case_loc, OPT_Wjump_misses_init, + "switch jumps over variable initialization"); + inform (switch_loc, "switch starts here"); + inform (DECL_SOURCE_LOCATION (b->decl), "%qD declared here", + b->decl); + } + } } if (switch_bindings->stmt_exprs > 0) @@ -3392,7 +3391,7 @@ static tree lookup_tag (enum tree_code code, tree name, int thislevel_only, - location_t *ploc) + location_t *ploc) { struct c_binding *b = I_TAG_BINDING (name); int thislevel = 0; @@ -3405,12 +3404,12 @@ if (thislevel_only || TREE_CODE (b->decl) != code) { /* For our purposes, a tag in the external scope is the same as - a tag in the file scope. (Primarily relevant to Objective-C - and its builtin structure tags, which get pushed before the - file scope is created.) */ + a tag in the file scope. (Primarily relevant to Objective-C + and its builtin structure tags, which get pushed before the + file scope is created.) */ if (B_IN_CURRENT_SCOPE (b) - || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b))) - thislevel = 1; + || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b))) + thislevel = 1; } if (thislevel_only && !thislevel) @@ -3423,11 +3422,11 @@ 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.) */ + 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 (); + pending_xref_error (); } if (ploc != NULL) @@ -3446,7 +3445,7 @@ { if (pending_invalid_xref != 0) error_at (pending_invalid_xref_location, "%qE defined as wrong kind of tag", - pending_invalid_xref); + pending_invalid_xref); pending_invalid_xref = 0; } @@ -3515,7 +3514,7 @@ /* Even in C99, which has a real boolean type. */ pushdecl (build_decl (UNKNOWN_LOCATION, TYPE_DECL, get_identifier ("_Bool"), - boolean_type_node)); + boolean_type_node)); input_location = save_loc; @@ -3541,7 +3540,7 @@ size_t length = strlen (name); type = build_array_type (char_type_node, - build_index_type (size_int (length))); + build_index_type (size_int (length))); type = c_build_qualified_type (type, TYPE_QUAL_CONST); decl = build_decl (loc, VAR_DECL, id, type); @@ -3570,7 +3569,7 @@ { DECL_CONTEXT (decl) = current_function_decl; bind (id, decl, current_function_scope, - /*invisible=*/false, /*nested=*/false, UNKNOWN_LOCATION); + /*invisible=*/false, /*nested=*/false, UNKNOWN_LOCATION); } finish_decl (decl, loc, init, NULL_TREE, NULL_TREE); @@ -3591,7 +3590,7 @@ gcc_assert (!I_SYMBOL_BINDING (id)); bind (id, decl, external_scope, /*invisible=*/true, /*nested=*/false, - UNKNOWN_LOCATION); + UNKNOWN_LOCATION); /* Builtins in the implementation namespace are made visible without needing to be explicitly declared. See push_file_scope. */ @@ -3617,7 +3616,7 @@ gcc_assert (!I_SYMBOL_BINDING (id)); bind (id, decl, external_scope, /*invisible=*/false, /*nested=*/false, - UNKNOWN_LOCATION); + UNKNOWN_LOCATION); /* Builtins in the implementation namespace are made visible without needing to be explicitly declared. See push_file_scope. */ @@ -3719,26 +3718,14 @@ } } else - { - pending_invalid_xref = 0; - t = lookup_tag (code, name, 1, NULL); - - if (t == 0) - { - t = make_node (code); - pushtag (input_location, name, t); - } - } - } - else - { - if (warned != 1 && !in_system_header) - { - pedwarn (input_location, 0, - "useless type name in empty declaration"); - warned = 1; - } - } + { + if (warned != 1 && !in_system_header) + { + pedwarn (input_location, 0, + "useless type name in empty declaration"); + warned = 1; + } + } } else if (warned != 1 && !in_system_header && declspecs->typedef_p) { @@ -3779,9 +3766,9 @@ } if (!warned && !in_system_header && (declspecs->const_p - || declspecs->volatile_p - || declspecs->restrict_p - || declspecs->address_space)) + || declspecs->volatile_p + || declspecs->restrict_p + || declspecs->address_space)) { warning (0, "useless type qualifier in empty declaration"); warned = 2; @@ -3790,7 +3777,7 @@ if (warned != 1) { if (!found_tag) - pedwarn (input_location, 0, "empty declaration"); + pedwarn (input_location, 0, "empty declaration"); } } @@ -3803,24 +3790,24 @@ quals_from_declspecs (const struct c_declspecs *specs) { int quals = ((specs->const_p ? TYPE_QUAL_CONST : 0) - | (specs->volatile_p ? TYPE_QUAL_VOLATILE : 0) - | (specs->restrict_p ? TYPE_QUAL_RESTRICT : 0) - | (ENCODE_QUAL_ADDR_SPACE (specs->address_space))); + | (specs->volatile_p ? TYPE_QUAL_VOLATILE : 0) + | (specs->restrict_p ? TYPE_QUAL_RESTRICT : 0) + | (ENCODE_QUAL_ADDR_SPACE (specs->address_space))); gcc_assert (!specs->type - && !specs->decl_attr - && specs->typespec_word == cts_none - && specs->storage_class == csc_none - && !specs->typedef_p - && !specs->explicit_signed_p - && !specs->deprecated_p - && !specs->long_p - && !specs->long_long_p - && !specs->short_p - && !specs->signed_p - && !specs->unsigned_p - && !specs->complex_p - && !specs->inline_p - && !specs->thread_p); + && !specs->decl_attr + && specs->typespec_word == cts_none + && specs->storage_class == csc_none + && !specs->typedef_p + && !specs->explicit_signed_p + && !specs->deprecated_p + && !specs->long_p + && !specs->long_long_p + && !specs->short_p + && !specs->signed_p + && !specs->unsigned_p + && !specs->complex_p + && !specs->inline_p + && !specs->thread_p); return quals; } @@ -3836,11 +3823,11 @@ struct c_declarator * build_array_declarator (location_t loc, - tree expr, struct c_declspecs *quals, bool static_p, - bool vla_unspec_p) + tree expr, struct c_declspecs *quals, bool static_p, + bool vla_unspec_p) { struct c_declarator *declarator = XOBNEW (&parser_obstack, - struct c_declarator); + struct c_declarator); declarator->id_loc = loc; declarator->kind = cdk_array; declarator->declarator = 0; @@ -3860,23 +3847,23 @@ if (!flag_isoc99) { if (static_p || quals != NULL) - pedwarn (loc, OPT_pedantic, - "ISO C90 does not support %<static%> or type " - "qualifiers in parameter array declarators"); + pedwarn (loc, OPT_pedantic, + "ISO C90 does not support %<static%> or type " + "qualifiers in parameter array declarators"); if (vla_unspec_p) - pedwarn (loc, OPT_pedantic, - "ISO C90 does not support %<[*]%> array declarators"); + pedwarn (loc, OPT_pedantic, + "ISO C90 does not support %<[*]%> array declarators"); } if (vla_unspec_p) { if (!current_scope->parm_flag) - { - /* C99 6.7.5.2p4 */ - error_at (loc, "%<[*]%> not allowed in other than " - "function prototype scope"); - declarator->u.array.vla_unspec_p = false; - return NULL; - } + { + /* C99 6.7.5.2p4 */ + error_at (loc, "%<[*]%> not allowed in other than " + "function prototype scope"); + declarator->u.array.vla_unspec_p = false; + return NULL; + } current_scope->had_vla_unspec = true; } return declarator; @@ -3888,7 +3875,7 @@ struct c_declarator * set_array_declarator_inner (struct c_declarator *decl, - struct c_declarator *inner) + struct c_declarator *inner) { decl->declarator = inner; return decl; @@ -3915,9 +3902,9 @@ { complete_array_type (&type, elt, false); DECL_SIZE (decl) - = size_binop (PLUS_EXPR, DECL_SIZE (decl), TYPE_SIZE (type)); + = size_binop (PLUS_EXPR, DECL_SIZE (decl), TYPE_SIZE (type)); DECL_SIZE_UNIT (decl) - = size_binop (PLUS_EXPR, DECL_SIZE_UNIT (decl), TYPE_SIZE_UNIT (type)); + = size_binop (PLUS_EXPR, DECL_SIZE_UNIT (decl), TYPE_SIZE_UNIT (type)); } } @@ -3929,7 +3916,7 @@ tree groktypename (struct c_type_name *type_name, tree *expr, - bool *expr_const_operands) + bool *expr_const_operands) { tree type; tree attrs = type_name->specs->attrs; @@ -3937,8 +3924,8 @@ type_name->specs->attrs = NULL_TREE; type = grokdeclarator (type_name->declarator, type_name->specs, TYPENAME, - false, NULL, &attrs, expr, expr_const_operands, - DEPRECATED_NORMAL); + false, NULL, &attrs, expr, expr_const_operands, + DEPRECATED_NORMAL); /* Apply attributes. */ decl_attributes (&type, attrs, 0); @@ -3963,7 +3950,7 @@ tree start_decl (struct c_declarator *declarator, struct c_declspecs *declspecs, - bool initialized, tree attributes) + bool initialized, tree attributes) { tree decl; tree tem; @@ -3976,8 +3963,8 @@ deprecated_state = DEPRECATED_SUPPRESS; decl = grokdeclarator (declarator, declspecs, - NORMAL, initialized, NULL, &attributes, &expr, NULL, - deprecated_state); + NORMAL, initialized, NULL, &attributes, &expr, NULL, + deprecated_state); if (!decl) return 0; @@ -3994,64 +3981,64 @@ switch (TREE_CODE (decl)) { case TYPE_DECL: - error ("typedef %qD is initialized (use __typeof__ instead)", decl); - initialized = 0; - break; + error ("typedef %qD is initialized (use __typeof__ instead)", decl); + initialized = 0; + break; case FUNCTION_DECL: - error ("function %qD is initialized like a variable", decl); - initialized = 0; - break; + error ("function %qD is initialized like a variable", decl); + initialized = 0; + break; case PARM_DECL: - /* DECL_INITIAL in a PARM_DECL is really DECL_ARG_TYPE. */ - error ("parameter %qD is initialized", decl); - initialized = 0; - break; + /* DECL_INITIAL in a PARM_DECL is really DECL_ARG_TYPE. */ + error ("parameter %qD is initialized", 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 %qD has initializer but incomplete type", decl); - initialized = 0; - } - else if (C_DECL_VARIABLE_SIZE (decl)) - { - /* Although C99 is unclear about whether incomplete arrays - of VLAs themselves count as VLAs, it does not make - sense to permit them to be initialized given that - ordinary VLAs may not be initialized. */ - error ("variable-sized object may not be initialized"); - initialized = 0; - } + /* 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 %qD has initializer but incomplete type", decl); + initialized = 0; + } + else if (C_DECL_VARIABLE_SIZE (decl)) + { + /* Although C99 is unclear about whether incomplete arrays + of VLAs themselves count as VLAs, it does not make + sense to permit them to be initialized given that + ordinary VLAs may not be initialized. */ + error ("variable-sized object may not be initialized"); + initialized = 0; + } } if (initialized) { if (current_scope == file_scope) - TREE_STATIC (decl) = 1; + 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. */ + 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; } @@ -4087,12 +4074,12 @@ && !flag_gnu89_inline && TREE_CODE (decl) == FUNCTION_DECL && (lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (decl)) - || current_function_decl)) + || current_function_decl)) { if (declspecs->storage_class == csc_auto && current_scope != file_scope) - ; + ; else if (declspecs->storage_class != csc_static) - DECL_EXTERNAL (decl) = !DECL_EXTERNAL (decl); + DECL_EXTERNAL (decl) = !DECL_EXTERNAL (decl); } if (TREE_CODE (decl) == FUNCTION_DECL @@ -4101,7 +4088,7 @@ struct c_declarator *ce = declarator; if (ce->kind == cdk_pointer) - ce = declarator->declarator; + ce = declarator->declarator; if (ce->kind == cdk_function) { tree args = ce->u.arg_info->parms; @@ -4120,7 +4107,7 @@ && DECL_UNINLINABLE (decl) && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl))) warning (OPT_Wattributes, "inline function %q+D given attribute noinline", - decl); + decl); /* C99 6.7.4p3: An inline definition of a function with external linkage shall not contain a definition of a modifiable object @@ -4132,7 +4119,7 @@ && DECL_DECLARED_INLINE_P (current_function_decl) && DECL_EXTERNAL (current_function_decl)) record_inline_static (input_location, current_function_decl, - decl, csi_modifiable); + decl, csi_modifiable); if (c_dialect_objc () && (TREE_CODE (decl) == VAR_DECL @@ -4191,7 +4178,7 @@ void finish_decl (tree decl, location_t init_loc, tree init, - tree origtype, tree asmspec_tree) + tree origtype, tree asmspec_tree) { tree type; bool was_incomplete = (DECL_SIZE (decl) == 0); @@ -4223,8 +4210,8 @@ store_init_value (init_loc, decl, init, origtype); if (c_dialect_objc () && (TREE_CODE (decl) == VAR_DECL - || TREE_CODE (decl) == FUNCTION_DECL - || TREE_CODE (decl) == FIELD_DECL)) + || TREE_CODE (decl) == FUNCTION_DECL + || TREE_CODE (decl) == FIELD_DECL)) objc_check_decl (decl); type = TREE_TYPE (decl); @@ -4235,65 +4222,65 @@ && TREE_CODE (decl) != TYPE_DECL) { bool 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)); + = (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 (&TREE_TYPE (decl), DECL_INITIAL (decl), - do_default); + = complete_array_type (&TREE_TYPE (decl), DECL_INITIAL (decl), + do_default); /* Get the completed type made by complete_array_type. */ type = TREE_TYPE (decl); switch (failure) - { - case 1: - error ("initializer fails to determine size of %q+D", decl); - break; - - case 2: - if (do_default) - error ("array size missing in %q+D", 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; - break; - - case 3: - error ("zero or negative size array %q+D", decl); - break; - - case 0: - /* For global variables, update the copy of the type that - exists in the binding. */ - if (TREE_PUBLIC (decl)) - { - struct c_binding *b_ext = I_SYMBOL_BINDING (DECL_NAME (decl)); - while (b_ext && !B_IN_EXTERNAL_SCOPE (b_ext)) - b_ext = b_ext->shadowed; - if (b_ext) - { - if (b_ext->u.type) - b_ext->u.type = composite_type (b_ext->u.type, type); - else - b_ext->u.type = type; - } - } - break; - - default: - gcc_unreachable (); - } + { + case 1: + error ("initializer fails to determine size of %q+D", decl); + break; + + case 2: + if (do_default) + error ("array size missing in %q+D", 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; + break; + + case 3: + error ("zero or negative size array %q+D", decl); + break; + + case 0: + /* For global variables, update the copy of the type that + exists in the binding. */ + if (TREE_PUBLIC (decl)) + { + struct c_binding *b_ext = I_SYMBOL_BINDING (DECL_NAME (decl)); + while (b_ext && !B_IN_EXTERNAL_SCOPE (b_ext)) + b_ext = b_ext->shadowed; + if (b_ext) + { + if (b_ext->u.type) + b_ext->u.type = composite_type (b_ext->u.type, type); + else + b_ext->u.type = type; + } + } + break; + + default: + gcc_unreachable (); + } if (DECL_INITIAL (decl)) - TREE_TYPE (DECL_INITIAL (decl)) = type; + TREE_TYPE (DECL_INITIAL (decl)) = type; layout_decl (decl, 0); } @@ -4301,42 +4288,42 @@ if (TREE_CODE (decl) == VAR_DECL) { if (init && TREE_CODE (init) == CONSTRUCTOR) - add_flexible_array_elts_to_size (decl, init); + add_flexible_array_elts_to_size (decl, init); if (DECL_SIZE (decl) == 0 && TREE_TYPE (decl) != error_mark_node - && COMPLETE_TYPE_P (TREE_TYPE (decl))) - layout_decl (decl, 0); + && 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 ("storage size of %q+D isn%'t known", decl); - TREE_TYPE (decl) = error_mark_node; - } + /* 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 ("storage size of %q+D isn%'t known", 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 ("storage size of %q+D isn%'t constant", decl); - TREE_TYPE (decl) = error_mark_node; - } - } + && DECL_SIZE (decl) != 0) + { + if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST) + constant_expression_warning (DECL_SIZE (decl)); + else + { + error ("storage size of %q+D isn%'t constant", decl); + TREE_TYPE (decl) = error_mark_node; + } + } if (TREE_USED (type)) { @@ -4351,7 +4338,7 @@ if (TREE_CODE (decl) == FUNCTION_DECL && asmspec) { if (DECL_BUILT_IN_CLASS (decl) == BUILT_IN_NORMAL) - set_builtin_user_assembler_name (decl, asmspec); + set_builtin_user_assembler_name (decl, asmspec); set_user_assembler_name (decl, asmspec); } @@ -4366,98 +4353,98 @@ { /* Determine the ELF visibility. */ if (TREE_PUBLIC (decl)) - c_determine_visibility (decl); + c_determine_visibility (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); + objc_check_decl (decl); if (asmspec) - { - /* 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 (!DECL_FILE_SCOPE_P (decl) - && TREE_CODE (decl) == VAR_DECL - && !C_DECL_REGISTER (decl) - && !TREE_STATIC (decl)) - warning (0, "ignoring asm-specifier for non-static local " - "variable %q+D", decl); - else - set_user_assembler_name (decl, asmspec); - } + { + /* 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 (!DECL_FILE_SCOPE_P (decl) + && TREE_CODE (decl) == VAR_DECL + && !C_DECL_REGISTER (decl) + && !TREE_STATIC (decl)) + warning (0, "ignoring asm-specifier for non-static local " + "variable %q+D", decl); + else + set_user_assembler_name (decl, asmspec); + } 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, true, 0); - } + { + 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, true, 0); + } else - { - /* In conjunction with an ASMSPEC, the `register' - keyword indicates that we should place the variable - in a particular register. */ - if (asmspec && C_DECL_REGISTER (decl)) - { - DECL_HARD_REGISTER (decl) = 1; - /* This cannot be done for a structure with volatile - fields, on which DECL_REGISTER will have been - reset. */ - if (!DECL_REGISTER (decl)) - error ("cannot put object with volatile field into register"); - } - - if (TREE_CODE (decl) != FUNCTION_DECL) - { - /* If we're building a variable sized type, and we might be - reachable other than via the top of the current binding - level, then create a new BIND_EXPR so that we deallocate - the object at the right time. */ - /* Note that DECL_SIZE can be null due to errors. */ - if (DECL_SIZE (decl) - && !TREE_CONSTANT (DECL_SIZE (decl)) - && STATEMENT_LIST_HAS_LABEL (cur_stmt_list)) - { - tree bind; - bind = build3 (BIND_EXPR, void_type_node, NULL, NULL, NULL); - TREE_SIDE_EFFECTS (bind) = 1; - add_stmt (bind); - BIND_EXPR_BODY (bind) = push_stmt_list (); - } - add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl), - DECL_EXPR, decl)); - } - } + { + /* In conjunction with an ASMSPEC, the `register' + keyword indicates that we should place the variable + in a particular register. */ + if (asmspec && C_DECL_REGISTER (decl)) + { + DECL_HARD_REGISTER (decl) = 1; + /* This cannot be done for a structure with volatile + fields, on which DECL_REGISTER will have been + reset. */ + if (!DECL_REGISTER (decl)) + error ("cannot put object with volatile field into register"); + } + + if (TREE_CODE (decl) != FUNCTION_DECL) + { + /* If we're building a variable sized type, and we might be + reachable other than via the top of the current binding + level, then create a new BIND_EXPR so that we deallocate + the object at the right time. */ + /* Note that DECL_SIZE can be null due to errors. */ + if (DECL_SIZE (decl) + && !TREE_CONSTANT (DECL_SIZE (decl)) + && STATEMENT_LIST_HAS_LABEL (cur_stmt_list)) + { + tree bind; + bind = build3 (BIND_EXPR, void_type_node, NULL, NULL, NULL); + TREE_SIDE_EFFECTS (bind) = 1; + add_stmt (bind); + BIND_EXPR_BODY (bind) = push_stmt_list (); + } + add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl), + DECL_EXPR, 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; - } - } + { + /* 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 (TREE_CODE (decl) == TYPE_DECL) { if (!DECL_FILE_SCOPE_P (decl) - && variably_modified_type_p (TREE_TYPE (decl), NULL_TREE)) - add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl)); + && variably_modified_type_p (TREE_TYPE (decl), NULL_TREE)) + add_stmt (build_stmt (DECL_SOURCE_LOCATION (decl), DECL_EXPR, decl)); rest_of_decl_compilation (decl, DECL_FILE_SCOPE_P (decl), 0); } @@ -4519,7 +4506,7 @@ { tree attrs = parm->attrs; tree decl = grokdeclarator (parm->declarator, parm->specs, PARM, false, - NULL, &attrs, NULL, NULL, DEPRECATED_NORMAL); + NULL, &attrs, NULL, NULL, DEPRECATED_NORMAL); decl_attributes (&decl, attrs, 0); @@ -4536,7 +4523,7 @@ tree decl; decl = grokdeclarator (parm->declarator, parm->specs, PARM, false, NULL, - &attrs, NULL, NULL, DEPRECATED_NORMAL); + &attrs, NULL, NULL, DEPRECATED_NORMAL); decl_attributes (&decl, attrs, 0); decl = pushdecl (decl); @@ -4555,7 +4542,7 @@ if (pedantic && !current_scope->warned_forward_parm_decls) { pedwarn (input_location, OPT_pedantic, - "ISO C forbids forward parameter declarations"); + "ISO C forbids forward parameter declarations"); current_scope->warned_forward_parm_decls = true; } @@ -4598,7 +4585,7 @@ if (TREE_CODE (type) == ARRAY_TYPE && !COMPLETE_TYPE_P (type)) { int failure = complete_array_type (&TREE_TYPE (decl), - DECL_INITIAL (decl), true); + DECL_INITIAL (decl), true); gcc_assert (!failure); type = TREE_TYPE (decl); @@ -4645,7 +4632,7 @@ && (type_name->specs->typespec_kind == ctsk_tagdef || type_name->specs->typespec_kind == ctsk_tagfirstref)) warning_at (loc, OPT_Wc___compat, - "defining a type in a compound literal is invalid in C++"); + "defining a type in a compound literal is invalid in C++"); } /* Determine whether TYPE is a structure with a flexible array member, @@ -4664,10 +4651,10 @@ while (DECL_CHAIN (x) != NULL_TREE) x = DECL_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; + && 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 = DECL_CHAIN (x)) @@ -4690,8 +4677,8 @@ unsigned int max_width; unsigned HOST_WIDE_INT w; const char *name = (orig_name - ? identifier_to_locale (IDENTIFIER_POINTER (orig_name)) - : _("<anonymous>")); + ? identifier_to_locale (IDENTIFIER_POINTER (orig_name)) + : _("<anonymous>")); /* Detect and ignore out of range field width and process valid field widths. */ @@ -4703,29 +4690,29 @@ else { if (TREE_CODE (*width) != INTEGER_CST) - { - *width = c_fully_fold (*width, false, NULL); - if (TREE_CODE (*width) == INTEGER_CST) - pedwarn (input_location, OPT_pedantic, - "bit-field %qs width not an integer constant expression", - name); - } + { + *width = c_fully_fold (*width, false, NULL); + if (TREE_CODE (*width) == INTEGER_CST) + pedwarn (input_location, OPT_pedantic, + "bit-field %qs width not an integer constant expression", + name); + } if (TREE_CODE (*width) != INTEGER_CST) - { - error ("bit-field %qs width not an integer constant", name); - *width = integer_one_node; - } + { + error ("bit-field %qs width not an integer constant", name); + *width = integer_one_node; + } constant_expression_warning (*width); if (tree_int_cst_sgn (*width) < 0) - { - error ("negative width in bit-field %qs", name); - *width = integer_one_node; - } + { + error ("negative width in bit-field %qs", name); + *width = integer_one_node; + } else if (integer_zerop (*width) && orig_name) - { - error ("zero width for bit-field %qs", name); - *width = integer_one_node; - } + { + error ("zero width for bit-field %qs", name); + *width = integer_one_node; + } } /* Detect invalid bit-field type. */ @@ -4743,7 +4730,7 @@ && type_mv != unsigned_type_node && type_mv != boolean_type_node) pedwarn (input_location, OPT_pedantic, - "type of bit-field %qs is a GCC extension", name); + "type of bit-field %qs is a GCC extension", name); max_width = TYPE_PRECISION (*type); @@ -4760,9 +4747,9 @@ { struct lang_type *lt = TYPE_LANG_SPECIFIC (*type); if (!lt - || w < tree_int_cst_min_precision (lt->enum_min, TYPE_UNSIGNED (*type)) - || w < tree_int_cst_min_precision (lt->enum_max, TYPE_UNSIGNED (*type))) - warning (0, "%qs is narrower than values of its type", name); + || w < tree_int_cst_min_precision (lt->enum_min, TYPE_UNSIGNED (*type)) + || w < tree_int_cst_min_precision (lt->enum_max, TYPE_UNSIGNED (*type))) + warning (0, "%qs is narrower than values of its type", name); } } @@ -4778,48 +4765,48 @@ if (!flag_isoc99 && pedantic && warn_vla != 0) { if (const_size) - { - if (name) - pedwarn (input_location, OPT_Wvla, - "ISO C90 forbids array %qE whose size " - "can%'t be evaluated", - name); + { + if (name) + pedwarn (input_location, OPT_Wvla, + "ISO C90 forbids array %qE whose size " + "can%'t be evaluated", + name); + else + pedwarn (input_location, OPT_Wvla, "ISO C90 forbids array whose size " + "can%'t be evaluated"); + } else - pedwarn (input_location, OPT_Wvla, "ISO C90 forbids array whose size " - "can%'t be evaluated"); - } - else - { - if (name) - pedwarn (input_location, OPT_Wvla, - "ISO C90 forbids variable length array %qE", - name); - else - pedwarn (input_location, OPT_Wvla, "ISO C90 forbids variable length array"); - } + { + if (name) + pedwarn (input_location, OPT_Wvla, + "ISO C90 forbids variable length array %qE", + name); + else + pedwarn (input_location, OPT_Wvla, "ISO C90 forbids variable length array"); + } } else if (warn_vla > 0) { if (const_size) { - if (name) - warning (OPT_Wvla, - "the size of array %qE can" - "%'t be evaluated", name); - else - warning (OPT_Wvla, - "the size of array can %'t be evaluated"); - } + if (name) + warning (OPT_Wvla, + "the size of array %qE can" + "%'t be evaluated", name); + else + warning (OPT_Wvla, + "the size of array can %'t be evaluated"); + } else - { - if (name) - warning (OPT_Wvla, - "variable length array %qE is used", - name); - else - warning (OPT_Wvla, - "variable length array is used"); - } + { + if (name) + warning (OPT_Wvla, + "variable length array %qE is used", + name); + else + warning (OPT_Wvla, + "variable length array is used"); + } } } @@ -4892,10 +4879,10 @@ static tree grokdeclarator (const struct c_declarator *declarator, - struct c_declspecs *declspecs, - enum decl_context decl_context, bool initialized, tree *width, - tree *decl_attrs, tree *expr, bool *expr_const_operands, - enum deprecated_states deprecated_state) + struct c_declspecs *declspecs, + enum decl_context decl_context, bool initialized, tree *width, + tree *decl_attrs, tree *expr, bool *expr_const_operands, + enum deprecated_states deprecated_state) { tree type = declspecs->type; bool threadp = declspecs->thread_p; @@ -4943,38 +4930,38 @@ while (decl) switch (decl->kind) - { - case cdk_array: - loc = decl->id_loc; - /* FALL THRU. */ - - case cdk_function: - case cdk_pointer: - funcdef_syntax = (decl->kind == cdk_function); - decl = decl->declarator; - break; - - case cdk_attrs: - decl = decl->declarator; - break; - - case cdk_id: - loc = decl->id_loc; - if (decl->u.id) - name = decl->u.id; - decl = 0; - break; - - default: - gcc_unreachable (); - } + { + case cdk_array: + loc = decl->id_loc; + /* FALL THRU. */ + + case cdk_function: + case cdk_pointer: + funcdef_syntax = (decl->kind == cdk_function); + decl = decl->declarator; + break; + + case cdk_attrs: + decl = decl->declarator; + break; + + case cdk_id: + loc = decl->id_loc; + if (decl->u.id) + name = decl->u.id; + decl = 0; + break; + + default: + gcc_unreachable (); + } if (name == 0) { - gcc_assert (decl_context == PARM - || decl_context == TYPENAME - || (decl_context == FIELD - && declarator->kind == cdk_id)); - gcc_assert (!initialized); + gcc_assert (decl_context == PARM + || decl_context == TYPENAME + || (decl_context == FIELD + && declarator->kind == cdk_id)); + gcc_assert (!initialized); } } @@ -4998,9 +4985,9 @@ && variably_modified_type_p (type, NULL_TREE)) { if (name) - error_at (loc, "variably modified %qE at file scope", name); + error_at (loc, "variably modified %qE at file scope", name); else - error_at (loc, "variably modified field at file scope"); + error_at (loc, "variably modified field at file scope"); type = integer_type_node; } @@ -5011,21 +4998,21 @@ if (declspecs->default_int_p && !in_system_header) { /* Issue a warning if this is an ISO C 99 program or if - -Wreturn-type and this is a function, or if -Wimplicit; - prefer the former warning since it is more explicit. */ + -Wreturn-type and this is a function, or if -Wimplicit; + prefer the former warning since it is more explicit. */ if ((warn_implicit_int || warn_return_type || flag_isoc99) - && funcdef_flag) - warn_about_return_type = 1; + && funcdef_flag) + warn_about_return_type = 1; else - { - if (name) - pedwarn_c99 (loc, flag_isoc99 ? 0 : OPT_Wimplicit_int, - "type defaults to %<int%> in declaration of %qE", - name); - else - pedwarn_c99 (input_location, flag_isoc99 ? 0 : OPT_Wimplicit_int, - "type defaults to %<int%> in type name"); - } + { + if (name) + pedwarn_c99 (loc, flag_isoc99 ? 0 : OPT_Wimplicit_int, + "type defaults to %<int%> in declaration of %qE", + name); + else + pedwarn_c99 (input_location, flag_isoc99 ? 0 : OPT_Wimplicit_int, + "type defaults to %<int%> in type name"); + } } /* Adjust the type if a bit-field is being declared, @@ -5057,82 +5044,82 @@ if (pedantic && !flag_isoc99) { if (constp > 1) - pedwarn (loc, OPT_pedantic, "duplicate %<const%>"); + pedwarn (loc, OPT_pedantic, "duplicate %<const%>"); if (restrictp > 1) - pedwarn (loc, OPT_pedantic, "duplicate %<restrict%>"); + pedwarn (loc, OPT_pedantic, "duplicate %<restrict%>"); if (volatilep > 1) - pedwarn (loc, OPT_pedantic, "duplicate %<volatile%>"); + pedwarn (loc, OPT_pedantic, "duplicate %<volatile%>"); } if (!ADDR_SPACE_GENERIC_P (as1) && !ADDR_SPACE_GENERIC_P (as2) && as1 != as2) error_at (loc, "conflicting named address spaces (%s vs %s)", - c_addr_space_name (as1), c_addr_space_name (as2)); + c_addr_space_name (as1), c_addr_space_name (as2)); if (!flag_gen_aux_info && (TYPE_QUALS (element_type))) type = TYPE_MAIN_VARIANT (type); type_quals = ((constp ? TYPE_QUAL_CONST : 0) - | (restrictp ? TYPE_QUAL_RESTRICT : 0) - | (volatilep ? TYPE_QUAL_VOLATILE : 0) - | ENCODE_QUAL_ADDR_SPACE (address_space)); + | (restrictp ? TYPE_QUAL_RESTRICT : 0) + | (volatilep ? TYPE_QUAL_VOLATILE : 0) + | ENCODE_QUAL_ADDR_SPACE (address_space)); /* Warn about storage classes that are invalid for certain kinds of declarations (parameters, typenames, etc.). */ if (funcdef_flag && (threadp - || storage_class == csc_auto - || storage_class == csc_register - || storage_class == csc_typedef)) + || storage_class == csc_auto + || storage_class == csc_register + || storage_class == csc_typedef)) { if (storage_class == csc_auto) - pedwarn (loc, - (current_scope == file_scope) ? 0 : OPT_pedantic, - "function definition declared %<auto%>"); + pedwarn (loc, + (current_scope == file_scope) ? 0 : OPT_pedantic, + "function definition declared %<auto%>"); if (storage_class == csc_register) - error_at (loc, "function definition declared %<register%>"); + error_at (loc, "function definition declared %<register%>"); if (storage_class == csc_typedef) - error_at (loc, "function definition declared %<typedef%>"); + error_at (loc, "function definition declared %<typedef%>"); if (threadp) - error_at (loc, "function definition declared %<__thread%>"); + error_at (loc, "function definition declared %<__thread%>"); threadp = false; if (storage_class == csc_auto - || storage_class == csc_register - || storage_class == csc_typedef) - storage_class = csc_none; + || storage_class == csc_register + || storage_class == csc_typedef) + storage_class = csc_none; } else if (decl_context != NORMAL && (storage_class != csc_none || threadp)) { if (decl_context == PARM && storage_class == csc_register) - ; + ; else - { - switch (decl_context) - { - case FIELD: - if (name) - error_at (loc, "storage class specified for structure " - "field %qE", name); - else - error_at (loc, "storage class specified for structure field"); - break; - case PARM: - if (name) - error_at (loc, "storage class specified for parameter %qE", - name); - else - error_at (loc, "storage class specified for unnamed parameter"); - break; - default: - error_at (loc, "storage class specified for typename"); - break; - } - storage_class = csc_none; - threadp = false; - } + { + switch (decl_context) + { + case FIELD: + if (name) + error_at (loc, "storage class specified for structure " + "field %qE", name); + else + error_at (loc, "storage class specified for structure field"); + break; + case PARM: + if (name) + error_at (loc, "storage class specified for parameter %qE", + name); + else + error_at (loc, "storage class specified for unnamed parameter"); + break; + default: + error_at (loc, "storage class specified for typename"); + break; + } + storage_class = csc_none; + threadp = false; + } } else if (storage_class == csc_extern - && initialized - && !funcdef_flag) + && initialized + && !funcdef_flag) { /* 'extern' with initialization is invalid if not at file scope. */ if (current_scope == file_scope) @@ -5141,31 +5128,31 @@ and C++ intersection. */ if (!(warn_cxx_compat && constp)) warning_at (loc, 0, "%qE initialized and declared %<extern%>", - name); + name); } else - error_at (loc, "%qE has both %<extern%> and initializer", name); + error_at (loc, "%qE has both %<extern%> and initializer", name); } else if (current_scope == file_scope) { if (storage_class == csc_auto) - error_at (loc, "file-scope declaration of %qE specifies %<auto%>", - name); + error_at (loc, "file-scope declaration of %qE specifies %<auto%>", + name); if (pedantic && storage_class == csc_register) - pedwarn (input_location, OPT_pedantic, - "file-scope declaration of %qE specifies %<register%>", name); + pedwarn (input_location, OPT_pedantic, + "file-scope declaration of %qE specifies %<register%>", name); } else { if (storage_class == csc_extern && funcdef_flag) - error_at (loc, "nested function %qE declared %<extern%>", name); + error_at (loc, "nested function %qE declared %<extern%>", name); else if (threadp && storage_class == csc_none) - { - error_at (loc, "function-scope %qE implicitly auto and declared " - "%<__thread%>", - name); - threadp = false; - } + { + error_at (loc, "function-scope %qE implicitly auto and declared " + "%<__thread%>", + name); + threadp = false; + } } /* Now figure out the structure of the declarator proper. @@ -5181,38 +5168,38 @@ while (declarator && declarator->kind != cdk_id) { if (type == error_mark_node) - { - declarator = declarator->declarator; - continue; - } + { + declarator = declarator->declarator; + continue; + } /* Each level of DECLARATOR is either a cdk_array (for ...[..]), - a cdk_pointer (for *...), - a cdk_function (for ...(...)), - a cdk_attrs (for nested attributes), - or a cdk_id (for the name being declared - or the place in an absolute declarator - where the name was omitted). - For the last case, we have just exited the loop. - - At this point, TYPE is the type of elements of an array, - or for a function to return, or for a pointer to point to. - After this sequence of ifs, TYPE is the type of the - array or function or pointer, and DECLARATOR has had its - outermost layer removed. */ + a cdk_pointer (for *...), + a cdk_function (for ...(...)), + a cdk_attrs (for nested attributes), + or a cdk_id (for the name being declared + or the place in an absolute declarator + where the name was omitted). + For the last case, we have just exited the loop. + + At this point, TYPE is the type of elements of an array, + or for a function to return, or for a pointer to point to. + After this sequence of ifs, TYPE is the type of the + array or function or pointer, and DECLARATOR has had its + outermost layer removed. */ if (array_ptr_quals != TYPE_UNQUALIFIED - || array_ptr_attrs != NULL_TREE - || array_parm_static) - { - /* Only the innermost declarator (making a parameter be of - array type which is converted to pointer type) - may have static or type qualifiers. */ - error_at (loc, "static or type qualifiers in non-parameter array declarator"); - array_ptr_quals = TYPE_UNQUALIFIED; - array_ptr_attrs = NULL_TREE; - array_parm_static = 0; - } + || array_ptr_attrs != NULL_TREE + || array_parm_static) + { + /* Only the innermost declarator (making a parameter be of + array type which is converted to pointer type) + may have static or type qualifiers. */ + error_at (loc, "static or type qualifiers in non-parameter array declarator"); + array_ptr_quals = TYPE_UNQUALIFIED; + array_ptr_attrs = NULL_TREE; + array_parm_static = 0; + } switch (declarator->kind) { @@ -5272,6 +5259,7 @@ "functions"); type = error_mark_node; } + if (pedantic && !in_system_header && flexible_array_type_p (type)) pedwarn (loc, OPT_pedantic, "invalid use of structure with flexible array member"); @@ -5561,7 +5549,6 @@ really_funcdef = (t->kind == cdk_id); } - /* Declaring a function type. Make sure we have a valid type for the function to return. */ if (type == error_mark_node) @@ -5632,9 +5619,7 @@ } else #endif - { - type = build_function_type (type, arg_types); - } + type = build_function_type (type, arg_types); declarator = declarator->declarator; /* Set the TYPE_CONTEXTs for each tagged type which is local to @@ -5653,6 +5638,7 @@ { /* Merge any constancy or volatility into the target type for the pointer. */ + if (pedantic && TREE_CODE (type) == FUNCTION_TYPE && type_quals) pedwarn (loc, OPT_pedantic, @@ -5666,13 +5652,16 @@ emitted early enough to dominate all the possible later uses and late enough for the variables on which it depends to have been assigned. + This is expected to happen automatically when the pointed-to type has a name/declaration of it's own, but special attention is required if the type is anonymous. + We handle the NORMAL and FIELD contexts here by attaching an artificial TYPE_DECL to such pointed-to type. This forces the sizes evaluation at a safe point and ensures it is not deferred until e.g. within a deeper conditional context. + We expect nothing to be needed here for PARM or TYPENAME. Pushing a TYPE_DECL at this point for TYPENAME would actually be incorrect, as we might be in the middle of an expression @@ -5698,7 +5687,6 @@ that were given inside the `*'. */ type_quals = declarator->u.pointer_quals; - declarator = declarator->declarator; break; } @@ -5717,51 +5705,51 @@ if (!ADDR_SPACE_GENERIC_P (address_space)) { if (decl_context == NORMAL) - { - switch (storage_class) - { - case csc_auto: - error ("%qs combined with %<auto%> qualifier for %qE", - c_addr_space_name (address_space), name); - break; - case csc_register: - error ("%qs combined with %<register%> qualifier for %qE", - c_addr_space_name (address_space), name); - break; - case csc_none: - if (current_function_scope) - { - error ("%qs specified for auto variable %qE", - c_addr_space_name (address_space), name); - break; - } - break; - case csc_static: - case csc_extern: - case csc_typedef: - break; - default: - gcc_unreachable (); - } - } + { + switch (storage_class) + { + case csc_auto: + error ("%qs combined with %<auto%> qualifier for %qE", + c_addr_space_name (address_space), name); + break; + case csc_register: + error ("%qs combined with %<register%> qualifier for %qE", + c_addr_space_name (address_space), name); + break; + case csc_none: + if (current_function_scope) + { + error ("%qs specified for auto variable %qE", + c_addr_space_name (address_space), name); + break; + } + break; + case csc_static: + case csc_extern: + case csc_typedef: + break; + default: + gcc_unreachable (); + } + } else if (decl_context == PARM && TREE_CODE (type) != ARRAY_TYPE) - { - if (name) - error ("%qs specified for parameter %qE", - c_addr_space_name (address_space), name); - else - error ("%qs specified for unnamed parameter", - c_addr_space_name (address_space)); - } + { + if (name) + error ("%qs specified for parameter %qE", + c_addr_space_name (address_space), name); + else + error ("%qs specified for unnamed parameter", + c_addr_space_name (address_space)); + } else if (decl_context == FIELD) - { - if (name) - error ("%qs specified for structure field %qE", - c_addr_space_name (address_space), name); - else - error ("%qs specified for structure field", - c_addr_space_name (address_space)); - } + { + if (name) + error ("%qs specified for structure field %qE", + c_addr_space_name (address_space), name); + else + error ("%qs specified for structure field", + c_addr_space_name (address_space)); + } } /* Check the type and width of a bit-field. */ @@ -5776,11 +5764,11 @@ && TREE_OVERFLOW (TYPE_SIZE_UNIT (type))) { if (name) - error_at (loc, "size of array %qE is too large", name); + error_at (loc, "size of array %qE is too large", name); else - error_at (loc, "size of unnamed array is too large"); + error_at (loc, "size of unnamed array is too large"); /* If we proceed with the array type as it is, we'll eventually - crash in tree_low_cst(). */ + crash in tree_low_cst(). */ type = error_mark_node; } @@ -5790,36 +5778,36 @@ { tree decl; if (pedantic && TREE_CODE (type) == FUNCTION_TYPE - && type_quals) - pedwarn (loc, OPT_pedantic, - "ISO C forbids qualified function types"); + && type_quals) + pedwarn (loc, OPT_pedantic, + "ISO C forbids qualified function types"); if (type_quals) - type = c_build_qualified_type (type, type_quals); + type = c_build_qualified_type (type, type_quals); decl = build_decl (declarator->id_loc, - TYPE_DECL, declarator->u.id, type); + TYPE_DECL, declarator->u.id, type); if (declspecs->explicit_signed_p) - C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1; + C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1; if (declspecs->inline_p) - pedwarn (loc, 0,"typedef %q+D declared %<inline%>", decl); + pedwarn (loc, 0,"typedef %q+D declared %<inline%>", decl); if (warn_cxx_compat && declarator->u.id != NULL_TREE) - { - struct c_binding *b = I_TAG_BINDING (declarator->u.id); - - if (b != NULL - && b->decl != NULL_TREE - && (B_IN_CURRENT_SCOPE (b) - || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b))) - && TYPE_MAIN_VARIANT (b->decl) != TYPE_MAIN_VARIANT (type)) - { - warning_at (declarator->id_loc, OPT_Wc___compat, - ("using %qD as both a typedef and a tag is " - "invalid in C++"), - decl); - if (b->locus != UNKNOWN_LOCATION) - inform (b->locus, "originally defined here"); - } - } + { + struct c_binding *b = I_TAG_BINDING (declarator->u.id); + + if (b != NULL + && b->decl != NULL_TREE + && (B_IN_CURRENT_SCOPE (b) + || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b))) + && TYPE_MAIN_VARIANT (b->decl) != TYPE_MAIN_VARIANT (type)) + { + warning_at (declarator->id_loc, OPT_Wc___compat, + ("using %qD as both a typedef and a tag is " + "invalid in C++"), + decl); + if (b->locus != UNKNOWN_LOCATION) + inform (b->locus, "originally defined here"); + } + } return decl; } @@ -5830,15 +5818,15 @@ if (decl_context == TYPENAME) { /* Note that the grammar rejects storage classes in typenames - and fields. */ + and fields. */ gcc_assert (storage_class == csc_none && !threadp - && !declspecs->inline_p); + && !declspecs->inline_p); if (pedantic && TREE_CODE (type) == FUNCTION_TYPE - && type_quals) - pedwarn (loc, OPT_pedantic, - "ISO C forbids const or volatile function types"); + && type_quals) + pedwarn (loc, OPT_pedantic, + "ISO C forbids const or volatile function types"); if (type_quals) - type = c_build_qualified_type (type, type_quals); + type = c_build_qualified_type (type, type_quals); return type; } @@ -5847,7 +5835,7 @@ { /* C99 6.7.2.1p8 */ pedwarn (loc, OPT_pedantic, "a member of a structure or union cannot " - "have a variably modified type"); + "have a variably modified type"); } /* Aside from typedefs and type names (handle above), @@ -5858,10 +5846,10 @@ if (VOID_TYPE_P (type) && decl_context != PARM && !((decl_context != FIELD && TREE_CODE (type) != FUNCTION_TYPE) - && (storage_class == csc_extern - || (current_scope == file_scope - && !(storage_class == csc_static - || storage_class == csc_register))))) + && (storage_class == csc_extern + || (current_scope == file_scope + && !(storage_class == csc_static + || storage_class == csc_register))))) { error_at (loc, "variable or field %qE declared void", name); type = integer_type_node; @@ -5875,93 +5863,93 @@ if (decl_context == PARM) { - tree promoted_type; - - /* A parameter declared as an array of T is really a pointer to T. - One declared as a function is really a pointer to a function. */ - - if (TREE_CODE (type) == ARRAY_TYPE) - { - /* Transfer const-ness of array into that of type pointed to. */ - type = TREE_TYPE (type); - if (type_quals) - type = c_build_qualified_type (type, type_quals); - type = build_pointer_type (type); - type_quals = array_ptr_quals; - if (type_quals) - type = c_build_qualified_type (type, type_quals); - - /* We don't yet implement attributes in this context. */ - if (array_ptr_attrs != NULL_TREE) - warning_at (loc, OPT_Wattributes, - "attributes in parameter array declarator ignored"); - - size_varies = false; - } - else if (TREE_CODE (type) == FUNCTION_TYPE) - { - if (type_quals) - pedwarn (loc, OPT_pedantic, - "ISO C forbids qualified function types"); - if (type_quals) - type = c_build_qualified_type (type, type_quals); - type = build_pointer_type (type); - type_quals = TYPE_UNQUALIFIED; - } - else if (type_quals) - type = c_build_qualified_type (type, type_quals); - - decl = build_decl (declarator->id_loc, - PARM_DECL, declarator->u.id, type); - if (size_varies) - C_DECL_VARIABLE_SIZE (decl) = 1; - - /* Compute the type actually passed in the parmlist, - for the case where there is no prototype. - (For example, shorts and chars are passed as ints.) - When there is a prototype, this is overridden later. */ - - if (type == error_mark_node) - promoted_type = type; - else - promoted_type = c_type_promotes_to (type); - - DECL_ARG_TYPE (decl) = promoted_type; - if (declspecs->inline_p) - pedwarn (loc, 0, "parameter %q+D declared %<inline%>", decl); + tree promoted_type; + + /* A parameter declared as an array of T is really a pointer to T. + One declared as a function is really a pointer to a function. */ + + if (TREE_CODE (type) == ARRAY_TYPE) + { + /* Transfer const-ness of array into that of type pointed to. */ + type = TREE_TYPE (type); + if (type_quals) + type = c_build_qualified_type (type, type_quals); + type = build_pointer_type (type); + type_quals = array_ptr_quals; + if (type_quals) + type = c_build_qualified_type (type, type_quals); + + /* We don't yet implement attributes in this context. */ + if (array_ptr_attrs != NULL_TREE) + warning_at (loc, OPT_Wattributes, + "attributes in parameter array declarator ignored"); + + size_varies = false; + } + else if (TREE_CODE (type) == FUNCTION_TYPE) + { + if (type_quals) + pedwarn (loc, OPT_pedantic, + "ISO C forbids qualified function types"); + if (type_quals) + type = c_build_qualified_type (type, type_quals); + type = build_pointer_type (type); + type_quals = TYPE_UNQUALIFIED; + } + else if (type_quals) + type = c_build_qualified_type (type, type_quals); + + decl = build_decl (declarator->id_loc, + PARM_DECL, declarator->u.id, type); + if (size_varies) + C_DECL_VARIABLE_SIZE (decl) = 1; + + /* Compute the type actually passed in the parmlist, + for the case where there is no prototype. + (For example, shorts and chars are passed as ints.) + When there is a prototype, this is overridden later. */ + + if (type == error_mark_node) + promoted_type = type; + else + promoted_type = c_type_promotes_to (type); + + DECL_ARG_TYPE (decl) = promoted_type; + if (declspecs->inline_p) + pedwarn (loc, 0, "parameter %q+D declared %<inline%>", decl); } else if (decl_context == FIELD) { - /* Note that the grammar rejects storage classes in typenames - and fields. */ - gcc_assert (storage_class == csc_none && !threadp - && !declspecs->inline_p); - - /* Structure field. It may not be a function. */ - - if (TREE_CODE (type) == FUNCTION_TYPE) - { - error_at (loc, "field %qE declared as a function", name); - type = build_pointer_type (type); - } - else if (TREE_CODE (type) != ERROR_MARK - && !COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (type)) - { - if (name) - error_at (loc, "field %qE has incomplete type", name); - else - error_at (loc, "unnamed field has incomplete type"); - type = error_mark_node; - } - type = c_build_qualified_type (type, type_quals); - decl = build_decl (declarator->id_loc, - FIELD_DECL, declarator->u.id, type); - DECL_NONADDRESSABLE_P (decl) = bitfield; - if (bitfield && !declarator->u.id) - TREE_NO_WARNING (decl) = 1; - - if (size_varies) - C_DECL_VARIABLE_SIZE (decl) = 1; + /* Note that the grammar rejects storage classes in typenames + and fields. */ + gcc_assert (storage_class == csc_none && !threadp + && !declspecs->inline_p); + + /* Structure field. It may not be a function. */ + + if (TREE_CODE (type) == FUNCTION_TYPE) + { + error_at (loc, "field %qE declared as a function", name); + type = build_pointer_type (type); + } + else if (TREE_CODE (type) != ERROR_MARK + && !COMPLETE_OR_UNBOUND_ARRAY_TYPE_P (type)) + { + if (name) + error_at (loc, "field %qE has incomplete type", name); + else + error_at (loc, "unnamed field has incomplete type"); + type = error_mark_node; + } + type = c_build_qualified_type (type, type_quals); + decl = build_decl (declarator->id_loc, + FIELD_DECL, declarator->u.id, type); + DECL_NONADDRESSABLE_P (decl) = bitfield; + if (bitfield && !declarator->u.id) + TREE_NO_WARNING (decl) = 1; + + if (size_varies) + C_DECL_VARIABLE_SIZE (decl) = 1; } else if (TREE_CODE (type) == FUNCTION_TYPE) { @@ -5989,7 +5977,6 @@ } } - decl = build_decl (declarator->id_loc, FUNCTION_DECL, declarator->u.id, type); decl = build_decl_attribute_variant (decl, decl_attr); @@ -6040,76 +6027,76 @@ } else { - /* It's a variable. */ - /* An uninitialized decl with `extern' is a reference. */ - int extern_ref = !initialized && storage_class == csc_extern; - - type = c_build_qualified_type (type, type_quals); - - /* C99 6.2.2p7: It is invalid (compile-time undefined - behavior) to create an 'extern' declaration for a - variable if there is a global declaration that is - 'static' and the global declaration is not visible. - (If the static declaration _is_ currently visible, - the 'extern' declaration is taken to refer to that decl.) */ - if (extern_ref && current_scope != file_scope) - { - tree global_decl = identifier_global_value (declarator->u.id); - tree visible_decl = lookup_name (declarator->u.id); - - if (global_decl - && global_decl != visible_decl - && TREE_CODE (global_decl) == VAR_DECL - && !TREE_PUBLIC (global_decl)) - error_at (loc, "variable previously declared %<static%> " - "redeclared %<extern%>"); - } - - decl = build_decl (declarator->id_loc, - VAR_DECL, declarator->u.id, type); - if (size_varies) - C_DECL_VARIABLE_SIZE (decl) = 1; - - if (declspecs->inline_p) - pedwarn (loc, 0, "variable %q+D declared %<inline%>", decl); - - /* At file scope, an initialized extern declaration may follow - a static declaration. In that case, DECL_EXTERNAL will be - reset later in start_decl. */ - DECL_EXTERNAL (decl) = (storage_class == csc_extern); - - /* At file scope, the presence of a `static' or `register' storage - class specifier, or the absence of all storage class specifiers - makes this declaration a definition (perhaps tentative). Also, - the absence of `static' makes it public. */ - if (current_scope == file_scope) - { - TREE_PUBLIC (decl) = storage_class != csc_static; - TREE_STATIC (decl) = !extern_ref; - } - /* Not at file scope, only `static' makes a static definition. */ - else - { - TREE_STATIC (decl) = (storage_class == csc_static); - TREE_PUBLIC (decl) = extern_ref; - } - - if (threadp) - DECL_TLS_MODEL (decl) = decl_default_tls_model (decl); + /* It's a variable. */ + /* An uninitialized decl with `extern' is a reference. */ + int extern_ref = !initialized && storage_class == csc_extern; + + type = c_build_qualified_type (type, type_quals); + + /* C99 6.2.2p7: It is invalid (compile-time undefined + behavior) to create an 'extern' declaration for a + variable if there is a global declaration that is + 'static' and the global declaration is not visible. + (If the static declaration _is_ currently visible, + the 'extern' declaration is taken to refer to that decl.) */ + if (extern_ref && current_scope != file_scope) + { + tree global_decl = identifier_global_value (declarator->u.id); + tree visible_decl = lookup_name (declarator->u.id); + + if (global_decl + && global_decl != visible_decl + && TREE_CODE (global_decl) == VAR_DECL + && !TREE_PUBLIC (global_decl)) + error_at (loc, "variable previously declared %<static%> " + "redeclared %<extern%>"); + } + + decl = build_decl (declarator->id_loc, + VAR_DECL, declarator->u.id, type); + if (size_varies) + C_DECL_VARIABLE_SIZE (decl) = 1; + + if (declspecs->inline_p) + pedwarn (loc, 0, "variable %q+D declared %<inline%>", decl); + + /* At file scope, an initialized extern declaration may follow + a static declaration. In that case, DECL_EXTERNAL will be + reset later in start_decl. */ + DECL_EXTERNAL (decl) = (storage_class == csc_extern); + + /* At file scope, the presence of a `static' or `register' storage + class specifier, or the absence of all storage class specifiers + makes this declaration a definition (perhaps tentative). Also, + the absence of `static' makes it public. */ + if (current_scope == file_scope) + { + TREE_PUBLIC (decl) = storage_class != csc_static; + TREE_STATIC (decl) = !extern_ref; + } + /* Not at file scope, only `static' makes a static definition. */ + else + { + TREE_STATIC (decl) = (storage_class == csc_static); + TREE_PUBLIC (decl) = extern_ref; + } + + if (threadp) + DECL_TLS_MODEL (decl) = decl_default_tls_model (decl); } if ((storage_class == csc_extern - || (storage_class == csc_none - && TREE_CODE (type) == FUNCTION_TYPE - && !funcdef_flag)) - && variably_modified_type_p (type, NULL_TREE)) + || (storage_class == csc_none + && TREE_CODE (type) == FUNCTION_TYPE + && !funcdef_flag)) + && variably_modified_type_p (type, NULL_TREE)) { - /* C99 6.7.5.2p2 */ - if (TREE_CODE (type) == FUNCTION_TYPE) - error_at (loc, "non-nested function with variably modified type"); - else - error_at (loc, "object with variably modified type must have " - "no linkage"); + /* C99 6.7.5.2p2 */ + if (TREE_CODE (type) == FUNCTION_TYPE) + error_at (loc, "non-nested function with variably modified type"); + else + error_at (loc, "object with variably modified type must have " + "no linkage"); } /* Record `register' declaration for warnings on & @@ -6117,8 +6104,8 @@ if (storage_class == csc_register) { - C_DECL_REGISTER (decl) = 1; - DECL_REGISTER (decl) = 1; + C_DECL_REGISTER (decl) = 1; + DECL_REGISTER (decl) = 1; } /* Record constancy and volatility. */ @@ -6129,17 +6116,17 @@ will be ignored, and would even crash the compiler. Of course, this only makes sense on VAR,PARM, and RESULT decl's. */ if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (decl)) - && (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL - || TREE_CODE (decl) == RESULT_DECL)) + && (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL + || TREE_CODE (decl) == RESULT_DECL)) { - /* It is not an error for a structure with volatile fields to - be declared register, but reset DECL_REGISTER since it - cannot actually go in a register. */ - int was_reg = C_DECL_REGISTER (decl); - C_DECL_REGISTER (decl) = 0; - DECL_REGISTER (decl) = 0; - c_mark_addressable (decl); - C_DECL_REGISTER (decl) = was_reg; + /* It is not an error for a structure with volatile fields to + be declared register, but reset DECL_REGISTER since it + cannot actually go in a register. */ + int was_reg = C_DECL_REGISTER (decl); + C_DECL_REGISTER (decl) = 0; + DECL_REGISTER (decl) = 0; + c_mark_addressable (decl); + C_DECL_REGISTER (decl) = was_reg; } /* This is the earliest point at which we might know the assembler @@ -6147,17 +6134,17 @@ gcc_assert (!DECL_ASSEMBLER_NAME_SET_P (decl)); if (warn_cxx_compat - && TREE_CODE (decl) == VAR_DECL - && TREE_PUBLIC (decl) - && TREE_STATIC (decl) - && (TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE - || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE - || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE) - && TYPE_NAME (TREE_TYPE (decl)) == NULL_TREE) + && TREE_CODE (decl) == VAR_DECL + && TREE_PUBLIC (decl) + && TREE_STATIC (decl) + && (TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE + || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE + || TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE) + && TYPE_NAME (TREE_TYPE (decl)) == NULL_TREE) warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat, - ("non-local variable %qD with anonymous type is " - "questionable in C++"), - decl); + ("non-local variable %qD with anonymous type is " + "questionable in C++"), + decl); return decl; } @@ -6191,7 +6178,7 @@ if (arg_types == 0 && !funcdef_flag && !in_system_header) warning (OPT_Wstrict_prototypes, - "function declaration isn%'t a prototype"); + "function declaration isn%'t a prototype"); if (arg_types == error_mark_node) return 0; /* don't set TYPE_ARG_TYPES in this case */ @@ -6205,6 +6192,7 @@ } else arg_info->parms = arg_info->types; + arg_info->types = 0; return 0; } @@ -6215,13 +6203,13 @@ const char *errmsg; /* If there is a parameter of incomplete type in a definition, - this is an error. In a declaration this is valid, and a - struct or union type may be completed later, before any calls - or definition of the function. In the case where the tag was - first declared within the parameter list, a warning has - already been given. If a parameter has void type, then - however the function cannot be defined or called, so - warn. */ + this is an error. In a declaration this is valid, and a + struct or union type may be completed later, before any calls + or definition of the function. In the case where the tag was + first declared within the parameter list, a warning has + already been given. If a parameter has void type, then + however the function cannot be defined or called, so + warn. */ for (parm = arg_info->parms, typelt = arg_types, parmno = 1; parm; @@ -6330,19 +6318,19 @@ (by 'const' or 'volatile'), or has a storage class specifier ('register'), then the behavior is undefined; issue an error. Typedefs for 'void' are OK (see DR#157). */ - if (b->prev == 0 /* one binding */ + if (b->prev == 0 /* one binding */ && TREE_CODE (b->decl) == PARM_DECL /* which is a parameter */ && !DECL_NAME (b->decl) /* anonymous */ && VOID_TYPE_P (TREE_TYPE (b->decl))) /* of void type */ { if (TREE_THIS_VOLATILE (b->decl) - || TREE_READONLY (b->decl) - || C_DECL_REGISTER (b->decl)) - error ("%<void%> as only parameter may not be qualified"); + || TREE_READONLY (b->decl) + || C_DECL_REGISTER (b->decl)) + error ("%<void%> as only parameter may not be qualified"); /* There cannot be an ellipsis. */ if (ellipsis) - error ("%<void%> must be the only parameter"); + error ("%<void%> must be the only parameter"); arg_info->types = void_list_node; return arg_info; @@ -6516,33 +6504,33 @@ if (ref && TREE_CODE (ref) == code) { if (C_TYPE_DEFINED_IN_STRUCT (ref) - && loc != UNKNOWN_LOCATION - && warn_cxx_compat) - { - switch (code) - { - case ENUMERAL_TYPE: - warning_at (loc, OPT_Wc___compat, - ("enum type defined in struct or union " - "is not visible in C++")); - inform (refloc, "enum type defined here"); - break; - case RECORD_TYPE: - warning_at (loc, OPT_Wc___compat, - ("struct defined in struct or union " - "is not visible in C++")); - inform (refloc, "struct defined here"); - break; - case UNION_TYPE: - warning_at (loc, OPT_Wc___compat, - ("union defined in struct or union " - "is not visible in C++")); - inform (refloc, "union defined here"); - break; - default: - gcc_unreachable(); - } - } + && loc != UNKNOWN_LOCATION + && warn_cxx_compat) + { + switch (code) + { + case ENUMERAL_TYPE: + warning_at (loc, OPT_Wc___compat, + ("enum type defined in struct or union " + "is not visible in C++")); + inform (refloc, "enum type defined here"); + break; + case RECORD_TYPE: + warning_at (loc, OPT_Wc___compat, + ("struct defined in struct or union " + "is not visible in C++")); + inform (refloc, "struct defined here"); + break; + case UNION_TYPE: + warning_at (loc, OPT_Wc___compat, + ("union defined in struct or union " + "is not visible in C++")); + inform (refloc, "union defined here"); + break; + default: + gcc_unreachable(); + } + } ret.spec = ref; return ret; @@ -6557,7 +6545,7 @@ if (code == ENUMERAL_TYPE) { /* Give the type a default layout like unsigned int - to avoid crashing if it does not get defined. */ + to avoid crashing if it does not get defined. */ SET_TYPE_MODE (ref, TYPE_MODE (unsigned_type_node)); TYPE_ALIGN (ref) = TYPE_ALIGN (unsigned_type_node); TYPE_USER_ALIGN (ref) = 0; @@ -6595,7 +6583,7 @@ tree start_struct (location_t loc, enum tree_code code, tree name, - struct c_struct_parse_info **enclosing_struct_parse_info) + struct c_struct_parse_info **enclosing_struct_parse_info) { /* If there is already a tag defined at this scope (as a forward reference), just return it. */ @@ -6608,28 +6596,28 @@ if (ref && TREE_CODE (ref) == code) { if (TYPE_SIZE (ref)) - { - if (code == UNION_TYPE) - error_at (loc, "redefinition of %<union %E%>", name); - else - error_at (loc, "redefinition of %<struct %E%>", name); - if (refloc != UNKNOWN_LOCATION) - inform (refloc, "originally defined here"); - /* Don't create structures using a name already in use. */ - ref = NULL_TREE; - } + { + if (code == UNION_TYPE) + error_at (loc, "redefinition of %<union %E%>", name); + else + error_at (loc, "redefinition of %<struct %E%>", name); + if (refloc != UNKNOWN_LOCATION) + inform (refloc, "originally defined here"); + /* Don't create structures using a name already in use. */ + ref = NULL_TREE; + } else if (C_TYPE_BEING_DEFINED (ref)) - { - if (code == UNION_TYPE) - error_at (loc, "nested redefinition of %<union %E%>", name); - else - error_at (loc, "nested redefinition of %<struct %E%>", name); - /* Don't bother to report "originally defined here" for a - nested redefinition; the original definition should be - obvious. */ - /* Don't create structures that contain themselves. */ - ref = NULL_TREE; - } + { + if (code == UNION_TYPE) + error_at (loc, "nested redefinition of %<union %E%>", name); + else + error_at (loc, "nested redefinition of %<struct %E%>", name); + /* Don't bother to report "originally defined here" for a + nested redefinition; the original definition should be + obvious. */ + /* Don't create structures that contain themselves. */ + ref = NULL_TREE; + } } /* Otherwise create a forward-reference just so the tag is in scope. */ @@ -6655,10 +6643,10 @@ sizeof anyhow. */ if (warn_cxx_compat && (in_sizeof || in_typeof || in_alignof)) warning_at (loc, OPT_Wc___compat, - "defining type in %qs expression is invalid in C++", - (in_sizeof - ? "sizeof" - : (in_typeof ? "typeof" : "alignof"))); + "defining type in %qs expression is invalid in C++", + (in_sizeof + ? "sizeof" + : (in_typeof ? "typeof" : "alignof"))); return ref; } @@ -6676,8 +6664,8 @@ tree grokfield (location_t loc, - struct c_declarator *declarator, struct c_declspecs *declspecs, - tree width, tree *decl_attrs) + struct c_declarator *declarator, struct c_declspecs *declspecs, + tree width, tree *decl_attrs) { tree value; @@ -6707,7 +6695,7 @@ tree type = declspecs->type; bool type_ok = (TREE_CODE (type) == RECORD_TYPE - || TREE_CODE (type) == UNION_TYPE); + || TREE_CODE (type) == UNION_TYPE); bool ok = false; if (type_ok) @@ -6719,8 +6707,6 @@ else ok = false; } - - if (!ok) { pedwarn (loc, 0, "declaration does not declare anything"); @@ -6738,8 +6724,8 @@ } value = grokdeclarator (declarator, declspecs, FIELD, false, - width ? &width : NULL, decl_attrs, NULL, NULL, - DEPRECATED_NORMAL); + width ? &width : NULL, decl_attrs, NULL, NULL, + DEPRECATED_NORMAL); finish_decl (value, loc, NULL_TREE, NULL_TREE, NULL_TREE); DECL_INITIAL (value) = width; @@ -6747,20 +6733,20 @@ if (warn_cxx_compat && DECL_NAME (value) != NULL_TREE) { /* If we currently have a binding for this field, set the - in_struct field in the binding, so that we warn about lookups - which find it. */ + in_struct field in the binding, so that we warn about lookups + which find it. */ struct c_binding *b = I_SYMBOL_BINDING (DECL_NAME (value)); if (b != NULL) - { - /* If the in_struct field is not yet set, push it on a list - to be cleared when this struct is finished. */ - if (!b->in_struct) - { - VEC_safe_push (c_binding_ptr, heap, - struct_parse_info->fields, b); - b->in_struct = 1; - } - } + { + /* If the in_struct field is not yet set, push it on a list + to be cleared when this struct is finished. */ + if (!b->in_struct) + { + VEC_safe_push (c_binding_ptr, heap, + struct_parse_info->fields, b); + b->in_struct = 1; + } + } } return value; @@ -6944,7 +6930,7 @@ && fieldlist != NULL_TREE) { /* Use a pointer_set using the name of the typedef. We can use - a pointer_set because identifiers are interned. */ + a pointer_set because identifiers are interned. */ struct pointer_set_t *tset = pointer_set_create (); FOR_EACH_VEC_ELT (tree, struct_parse_info->typedefs_seen, ix, x) @@ -6963,6 +6949,7 @@ the typedef name is used. */ } } + pointer_set_destroy (tset); } @@ -6982,7 +6969,7 @@ tree finish_struct (location_t loc, tree t, tree fieldlist, tree attributes, - struct c_struct_parse_info *enclosing_struct_parse_info) + struct c_struct_parse_info *enclosing_struct_parse_info) { tree x; bool toplevel = file_scope == current_scope; @@ -7008,22 +6995,22 @@ } if (x == 0) - { - if (TREE_CODE (t) == UNION_TYPE) - { - if (fieldlist) - pedwarn (loc, OPT_pedantic, "union has no named members"); - else - pedwarn (loc, OPT_pedantic, "union has no members"); - } - else - { - if (fieldlist) - pedwarn (loc, OPT_pedantic, "struct has no named members"); - else - pedwarn (loc, OPT_pedantic, "struct has no members"); - } - } + { + if (TREE_CODE (t) == UNION_TYPE) + { + if (fieldlist) + pedwarn (loc, OPT_pedantic, "union has no named members"); + else + pedwarn (loc, OPT_pedantic, "union has no members"); + } + else + { + if (fieldlist) + pedwarn (loc, OPT_pedantic, "struct has no named members"); + else + pedwarn (loc, OPT_pedantic, "struct has no members"); + } + } } /* Install struct as DECL_CONTEXT of each field decl. @@ -7037,13 +7024,13 @@ for (x = fieldlist; x; x = DECL_CHAIN (x)) { if (TREE_TYPE (x) == error_mark_node) - continue; + continue; DECL_CONTEXT (x) = t; /* If any field is const, the structure type is pseudo-const. */ if (TREE_READONLY (x)) - C_TYPE_FIELDS_READONLY (t) = 1; + C_TYPE_FIELDS_READONLY (t) = 1; else { /* A field that is pseudo-const makes the structure likewise. */ @@ -7054,26 +7041,26 @@ } /* Any field that is volatile means variables of this type must be - treated in some ways as volatile. */ + treated in some ways as volatile. */ if (TREE_THIS_VOLATILE (x)) - C_TYPE_FIELDS_VOLATILE (t) = 1; + C_TYPE_FIELDS_VOLATILE (t) = 1; /* Any field of nominal variable size implies structure is too. */ if (C_DECL_VARIABLE_SIZE (x)) - C_TYPE_VARIABLE_SIZE (t) = 1; + C_TYPE_VARIABLE_SIZE (t) = 1; if (DECL_INITIAL (x)) - { - unsigned HOST_WIDE_INT width = tree_low_cst (DECL_INITIAL (x), 1); - DECL_SIZE (x) = bitsize_int (width); - DECL_BIT_FIELD (x) = 1; - SET_DECL_C_BIT_FIELD (x); - } + { + unsigned HOST_WIDE_INT width = tree_low_cst (DECL_INITIAL (x), 1); + DECL_SIZE (x) = bitsize_int (width); + DECL_BIT_FIELD (x) = 1; + SET_DECL_C_BIT_FIELD (x); + } if (TYPE_PACKED (t) - && (DECL_BIT_FIELD (x) - || TYPE_ALIGN (TREE_TYPE (x)) > BITS_PER_UNIT)) - DECL_PACKED (x) = 1; + && (DECL_BIT_FIELD (x) + || TYPE_ALIGN (TREE_TYPE (x)) > BITS_PER_UNIT)) + DECL_PACKED (x) = 1; /* Detect flexible array member in an invalid context. */ if (TREE_CODE (TREE_TYPE (x)) == ARRAY_TYPE @@ -7102,9 +7089,9 @@ } if (pedantic && TREE_CODE (t) == RECORD_TYPE - && flexible_array_type_p (TREE_TYPE (x))) - pedwarn (DECL_SOURCE_LOCATION (x), OPT_pedantic, - "invalid use of structure with flexible array member"); + && flexible_array_type_p (TREE_TYPE (x))) + pedwarn (DECL_SOURCE_LOCATION (x), OPT_pedantic, + "invalid use of structure with flexible array member"); if (DECL_NAME (x) || TREE_CODE (TREE_TYPE (x)) == RECORD_TYPE @@ -7126,19 +7113,19 @@ tree *fieldlistp = &fieldlist; while (*fieldlistp) if (TREE_CODE (*fieldlistp) == FIELD_DECL && DECL_INITIAL (*fieldlistp) - && TREE_TYPE (*fieldlistp) != error_mark_node) - { - unsigned HOST_WIDE_INT width - = tree_low_cst (DECL_INITIAL (*fieldlistp), 1); - tree type = TREE_TYPE (*fieldlistp); - if (width != TYPE_PRECISION (type)) - { - TREE_TYPE (*fieldlistp) - = c_build_bitfield_integer_type (width, TYPE_UNSIGNED (type)); - DECL_MODE (*fieldlistp) = TYPE_MODE (TREE_TYPE (*fieldlistp)); - } - DECL_INITIAL (*fieldlistp) = 0; - } + && TREE_TYPE (*fieldlistp) != error_mark_node) + { + unsigned HOST_WIDE_INT width + = tree_low_cst (DECL_INITIAL (*fieldlistp), 1); + tree type = TREE_TYPE (*fieldlistp); + if (width != TYPE_PRECISION (type)) + { + TREE_TYPE (*fieldlistp) + = c_build_bitfield_integer_type (width, TYPE_UNSIGNED (type)); + DECL_MODE (*fieldlistp) = TYPE_MODE (TREE_TYPE (*fieldlistp)); + } + DECL_INITIAL (*fieldlistp) = 0; + } else fieldlistp = &DECL_CHAIN (*fieldlistp); } @@ -7156,9 +7143,9 @@ for (x = fieldlist; x; x = DECL_CHAIN (x)) { - if (len > 15 || DECL_NAME (x) == NULL) - break; - len += 1; + if (len > 15 || DECL_NAME (x) == NULL) + break; + len += 1; } if (len > 15) @@ -7226,16 +7213,16 @@ { tree decl = TREE_VALUE (x); if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE) - layout_array_type (TREE_TYPE (decl)); + layout_array_type (TREE_TYPE (decl)); if (TREE_CODE (decl) != TYPE_DECL) - { - layout_decl (decl, 0); - if (c_dialect_objc ()) - objc_check_decl (decl); - rest_of_decl_compilation (decl, toplevel, 0); - if (!toplevel) - expand_decl (decl); - } + { + layout_decl (decl, 0); + if (c_dialect_objc ()) + objc_check_decl (decl); + rest_of_decl_compilation (decl, toplevel, 0); + if (!toplevel) + expand_decl (decl); + } } C_TYPE_INCOMPLETE_VARS (TYPE_MAIN_VARIANT (t)) = 0; @@ -7252,7 +7239,7 @@ to be bound now. */ if (cur_stmt_list && variably_modified_type_p (t, NULL_TREE)) add_stmt (build_stmt (loc, - DECL_EXPR, build_decl (loc, TYPE_DECL, NULL, t))); + DECL_EXPR, build_decl (loc, TYPE_DECL, NULL, t))); if (warn_cxx_compat) warn_cxx_compat_finish_struct (fieldlist); @@ -7320,10 +7307,10 @@ /* This enum is a named one that has been declared already. */ error_at (loc, "redeclaration of %<enum %E%>", name); if (enumloc != UNKNOWN_LOCATION) - inform (enumloc, "originally defined here"); + inform (enumloc, "originally defined here"); /* Completely replace its old definition. - The old enumerators remain defined, however. */ + The old enumerators remain defined, however. */ TYPE_VALUES (enumtype) = 0; } @@ -7338,10 +7325,10 @@ as C++ doesn't permit statement exprs within sizeof anyhow. */ if (warn_cxx_compat && (in_sizeof || in_typeof || in_alignof)) warning_at (loc, OPT_Wc___compat, - "defining type in %qs expression is invalid in C++", - (in_sizeof - ? "sizeof" - : (in_typeof ? "typeof" : "alignof"))); + "defining type in %qs expression is invalid in C++", + (in_sizeof + ? "sizeof" + : (in_typeof ? "typeof" : "alignof"))); return enumtype; } @@ -7371,13 +7358,13 @@ { minnode = maxnode = TREE_VALUE (values); for (pair = TREE_CHAIN (values); pair; pair = TREE_CHAIN (pair)) - { - tree value = TREE_VALUE (pair); - if (tree_int_cst_lt (maxnode, value)) - maxnode = value; - if (tree_int_cst_lt (value, minnode)) - minnode = value; - } + { + tree value = TREE_VALUE (pair); + if (tree_int_cst_lt (maxnode, value)) + maxnode = value; + if (tree_int_cst_lt (value, minnode)) + minnode = value; + } } /* Construct the final type of this enumeration. It is the same @@ -7386,16 +7373,16 @@ the values are negative. */ unsign = (tree_int_cst_sgn (minnode) >= 0); precision = MAX (tree_int_cst_min_precision (minnode, unsign), - tree_int_cst_min_precision (maxnode, unsign)); + tree_int_cst_min_precision (maxnode, unsign)); if (TYPE_PACKED (enumtype) || precision > TYPE_PRECISION (integer_type_node)) { tem = c_common_type_for_size (precision, unsign); if (tem == NULL) - { - warning (0, "enumeration values exceed range of largest integer"); - tem = long_long_integer_type_node; - } + { + warning (0, "enumeration values exceed range of largest integer"); + tem = long_long_integer_type_node; + } } else tem = unsign ? unsigned_type_node : integer_type_node; @@ -7410,7 +7397,7 @@ if (TYPE_PRECISION (enumtype)) { if (precision > TYPE_PRECISION (enumtype)) - error ("specified mode too small for enumeral values"); + error ("specified mode too small for enumeral values"); } else TYPE_PRECISION (enumtype) = TYPE_PRECISION (tem); @@ -7420,36 +7407,36 @@ if (values != error_mark_node) { /* Change the type of the enumerators to be the enum type. We - need to do this irrespective of the size of the enum, for - proper type checking. Replace the DECL_INITIALs of the - enumerators, and the value slots of the list, with copies - that have the enum type; they cannot be modified in place - because they may be shared (e.g. integer_zero_node) Finally, - change the purpose slots to point to the names of the decls. */ + need to do this irrespective of the size of the enum, for + proper type checking. Replace the DECL_INITIALs of the + enumerators, and the value slots of the list, with copies + that have the enum type; they cannot be modified in place + because they may be shared (e.g. integer_zero_node) Finally, + change the purpose slots to point to the names of the decls. */ for (pair = values; pair; pair = TREE_CHAIN (pair)) - { - tree enu = TREE_PURPOSE (pair); - tree ini = DECL_INITIAL (enu); - - TREE_TYPE (enu) = enumtype; - - /* The ISO C Standard mandates enumerators to have type int, - even though the underlying type of an enum type is - unspecified. However, GCC allows enumerators of any - integer type as an extensions. build_enumerator() - converts any enumerators that fit in an int to type int, - to avoid promotions to unsigned types when comparing - integers with enumerators that fit in the int range. - When -pedantic is given, build_enumerator() would have - already warned about those that don't fit. Here we - convert the rest to the enumerator type. */ - if (TREE_TYPE (ini) != integer_type_node) - ini = convert (enumtype, ini); - - DECL_INITIAL (enu) = ini; - TREE_PURPOSE (pair) = DECL_NAME (enu); - TREE_VALUE (pair) = ini; - } + { + tree enu = TREE_PURPOSE (pair); + tree ini = DECL_INITIAL (enu); + + TREE_TYPE (enu) = enumtype; + + /* The ISO C Standard mandates enumerators to have type int, + even though the underlying type of an enum type is + unspecified. However, GCC allows enumerators of any + integer type as an extensions. build_enumerator() + converts any enumerators that fit in an int to type int, + to avoid promotions to unsigned types when comparing + integers with enumerators that fit in the int range. + When -pedantic is given, build_enumerator() would have + already warned about those that don't fit. Here we + convert the rest to the enumerator type. */ + if (TREE_TYPE (ini) != integer_type_node) + ini = convert (enumtype, ini); + + DECL_INITIAL (enu) = ini; + TREE_PURPOSE (pair) = DECL_NAME (enu); + TREE_VALUE (pair) = ini; + } TYPE_VALUES (enumtype) = values; } @@ -7465,7 +7452,7 @@ for (tem = TYPE_MAIN_VARIANT (enumtype); tem; tem = TYPE_NEXT_VARIANT (tem)) { if (tem == enumtype) - continue; + continue; TYPE_VALUES (tem) = TYPE_VALUES (enumtype); TYPE_MIN_VALUE (tem) = TYPE_MIN_VALUE (enumtype); TYPE_MAX_VALUE (tem) = TYPE_MAX_VALUE (enumtype); @@ -7510,37 +7497,37 @@ if (value != 0) { /* Don't issue more errors for error_mark_node (i.e. an - undeclared identifier) - just ignore the value expression. */ + undeclared identifier) - just ignore the value expression. */ if (value == error_mark_node) - value = 0; + value = 0; else if (!INTEGRAL_TYPE_P (TREE_TYPE (value))) - { - error_at (loc, "enumerator value for %qE is not an integer constant", - name); - value = 0; - } + { + error_at (loc, "enumerator value for %qE is not an integer constant", + name); + value = 0; + } else - { - if (TREE_CODE (value) != INTEGER_CST) - { - value = c_fully_fold (value, false, NULL); - if (TREE_CODE (value) == INTEGER_CST) - pedwarn (loc, OPT_pedantic, - "enumerator value for %qE is not an integer " - "constant expression", name); - } - if (TREE_CODE (value) != INTEGER_CST) - { - error ("enumerator value for %qE is not an integer constant", - name); - value = 0; - } - else - { - value = default_conversion (value); - constant_expression_warning (value); - } - } + { + if (TREE_CODE (value) != INTEGER_CST) + { + value = c_fully_fold (value, false, NULL); + if (TREE_CODE (value) == INTEGER_CST) + pedwarn (loc, OPT_pedantic, + "enumerator value for %qE is not an integer " + "constant expression", name); + } + if (TREE_CODE (value) != INTEGER_CST) + { + error ("enumerator value for %qE is not an integer constant", + name); + value = 0; + } + else + { + value = default_conversion (value); + constant_expression_warning (value); + } + } } /* Default based on previous value. */ @@ -7550,7 +7537,7 @@ { value = the_enum->enum_next_value; if (the_enum->enum_overflow) - error_at (loc, "overflow in enumeration values"); + error_at (loc, "overflow in enumeration values"); } /* Even though the underlying type of an enum is unspecified, the type of enumeration constants is explicitly defined as int @@ -7558,7 +7545,7 @@ an extension. */ else if (!int_fits_type_p (value, integer_type_node)) pedwarn (loc, OPT_pedantic, - "ISO C restricts enumerator values to range of %<int%>"); + "ISO C restricts enumerator values to range of %<int%>"); /* The ISO C Standard mandates enumerators to have type int, even though the underlying type of an enum type is unspecified. @@ -7582,10 +7569,10 @@ type = TREE_TYPE (value); type = c_common_type_for_size (MAX (TYPE_PRECISION (type), - TYPE_PRECISION (integer_type_node)), - (TYPE_PRECISION (type) - >= TYPE_PRECISION (integer_type_node) - && TYPE_UNSIGNED (type))); + TYPE_PRECISION (integer_type_node)), + (TYPE_PRECISION (type) + >= TYPE_PRECISION (integer_type_node) + && TYPE_UNSIGNED (type))); decl = build_decl (decl_loc, CONST_DECL, name, type); DECL_INITIAL (decl) = convert (type, value); @@ -7671,7 +7658,7 @@ int start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, - tree attributes) + tree attributes) { tree decl1, old_decl; tree restype, resdecl; @@ -7714,18 +7701,18 @@ && DECL_UNINLINABLE (decl1) && lookup_attribute ("noinline", DECL_ATTRIBUTES (decl1))) warning_at (loc, OPT_Wattributes, - "inline function %qD given attribute noinline", - decl1); + "inline function %qD given attribute noinline", + decl1); /* Handle gnu_inline attribute. */ if (declspecs->inline_p && !flag_gnu89_inline && TREE_CODE (decl1) == FUNCTION_DECL && (lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (decl1)) - || current_function_decl)) + || current_function_decl)) { if (declspecs->storage_class != csc_static) - DECL_EXTERNAL (decl1) = !DECL_EXTERNAL (decl1); + DECL_EXTERNAL (decl1) = !DECL_EXTERNAL (decl1); } announce_function (decl1); @@ -7735,14 +7722,14 @@ error_at (loc, "return type is an incomplete type"); /* Make it return void instead. */ TREE_TYPE (decl1) - = build_function_type (void_type_node, - TYPE_ARG_TYPES (TREE_TYPE (decl1))); + = build_function_type (void_type_node, + TYPE_ARG_TYPES (TREE_TYPE (decl1))); } if (warn_about_return_type) pedwarn_c99 (loc, flag_isoc99 ? 0 - : (warn_return_type ? OPT_Wreturn_type : OPT_Wimplicit_int), - "return type defaults to %<int%>"); + : (warn_return_type ? OPT_Wreturn_type : OPT_Wimplicit_int), + "return type defaults to %<int%>"); /* Make the init_value nonzero so pushdecl knows this is not tentative. error_mark_node is replaced below (in pop_scope) with the BLOCK. */ @@ -7763,47 +7750,47 @@ if (!prototype_p (TREE_TYPE (decl1))) { if (old_decl != 0 && TREE_CODE (TREE_TYPE (old_decl)) == FUNCTION_TYPE - && comptypes (TREE_TYPE (TREE_TYPE (decl1)), - TREE_TYPE (TREE_TYPE (old_decl)))) - { - TREE_TYPE (decl1) = composite_type (TREE_TYPE (old_decl), - TREE_TYPE (decl1)); - current_function_prototype_locus = DECL_SOURCE_LOCATION (old_decl); - current_function_prototype_built_in - = C_DECL_BUILTIN_PROTOTYPE (old_decl); - current_function_prototype_arg_types - = TYPE_ARG_TYPES (TREE_TYPE (decl1)); - } + && comptypes (TREE_TYPE (TREE_TYPE (decl1)), + TREE_TYPE (TREE_TYPE (old_decl)))) + { + TREE_TYPE (decl1) = composite_type (TREE_TYPE (old_decl), + TREE_TYPE (decl1)); + current_function_prototype_locus = DECL_SOURCE_LOCATION (old_decl); + current_function_prototype_built_in + = C_DECL_BUILTIN_PROTOTYPE (old_decl); + current_function_prototype_arg_types + = TYPE_ARG_TYPES (TREE_TYPE (decl1)); + } if (TREE_PUBLIC (decl1)) - { - /* If there is an external prototype declaration of this - function, record its location but do not copy information - to this decl. This may be an invisible declaration - (built-in or in a scope which has finished) or simply - have more refined argument types than any declaration - found above. */ - struct c_binding *b; - for (b = I_SYMBOL_BINDING (DECL_NAME (decl1)); b; b = b->shadowed) - if (B_IN_SCOPE (b, external_scope)) - break; - if (b) - { - tree ext_decl, ext_type; - ext_decl = b->decl; - ext_type = b->u.type ? b->u.type : TREE_TYPE (ext_decl); - if (TREE_CODE (ext_type) == FUNCTION_TYPE - && comptypes (TREE_TYPE (TREE_TYPE (decl1)), - TREE_TYPE (ext_type))) - { - current_function_prototype_locus - = DECL_SOURCE_LOCATION (ext_decl); - current_function_prototype_built_in - = C_DECL_BUILTIN_PROTOTYPE (ext_decl); - current_function_prototype_arg_types - = TYPE_ARG_TYPES (ext_type); - } - } - } + { + /* If there is an external prototype declaration of this + function, record its location but do not copy information + to this decl. This may be an invisible declaration + (built-in or in a scope which has finished) or simply + have more refined argument types than any declaration + found above. */ + struct c_binding *b; + for (b = I_SYMBOL_BINDING (DECL_NAME (decl1)); b; b = b->shadowed) + if (B_IN_SCOPE (b, external_scope)) + break; + if (b) + { + tree ext_decl, ext_type; + ext_decl = b->decl; + ext_type = b->u.type ? b->u.type : TREE_TYPE (ext_decl); + if (TREE_CODE (ext_type) == FUNCTION_TYPE + && comptypes (TREE_TYPE (TREE_TYPE (decl1)), + TREE_TYPE (ext_type))) + { + current_function_prototype_locus + = DECL_SOURCE_LOCATION (ext_decl); + current_function_prototype_built_in + = C_DECL_BUILTIN_PROTOTYPE (ext_decl); + current_function_prototype_arg_types + = TYPE_ARG_TYPES (ext_type); + } + } + } } /* Optionally warn of old-fashioned def with no previous prototype. */ @@ -7812,15 +7799,15 @@ && !prototype_p (TREE_TYPE (decl1)) && C_DECL_ISNT_PROTOTYPE (old_decl)) warning_at (loc, OPT_Wstrict_prototypes, - "function declaration isn%'t a prototype"); + "function declaration isn%'t a prototype"); /* Optionally warn of any global def with no previous prototype. */ else if (warn_missing_prototypes - && old_decl != error_mark_node - && TREE_PUBLIC (decl1) - && !MAIN_NAME_P (DECL_NAME (decl1)) - && C_DECL_ISNT_PROTOTYPE (old_decl)) + && old_decl != error_mark_node + && TREE_PUBLIC (decl1) + && !MAIN_NAME_P (DECL_NAME (decl1)) + && C_DECL_ISNT_PROTOTYPE (old_decl)) warning_at (loc, OPT_Wmissing_prototypes, - "no previous prototype for %qD", decl1); + "no previous prototype for %qD", decl1); /* Optionally warn of any def with no previous prototype if the function has already been used. */ else if (warn_missing_prototypes @@ -7829,24 +7816,24 @@ && TREE_USED (old_decl) && !prototype_p (TREE_TYPE (old_decl))) warning_at (loc, OPT_Wmissing_prototypes, - "%qD was used with no prototype before its definition", decl1); + "%qD was used with no prototype before its definition", decl1); /* Optionally warn of any global def with no previous declaration. */ else if (warn_missing_declarations - && TREE_PUBLIC (decl1) - && old_decl == 0 - && !MAIN_NAME_P (DECL_NAME (decl1))) + && TREE_PUBLIC (decl1) + && old_decl == 0 + && !MAIN_NAME_P (DECL_NAME (decl1))) warning_at (loc, OPT_Wmissing_declarations, - "no previous declaration for %qD", - decl1); + "no previous declaration for %qD", + decl1); /* Optionally warn of any def with no previous declaration if the function has already been used. */ else if (warn_missing_declarations - && old_decl != 0 - && old_decl != error_mark_node - && TREE_USED (old_decl) - && C_DECL_IMPLICIT (old_decl)) + && old_decl != 0 + && old_decl != error_mark_node + && TREE_USED (old_decl) + && C_DECL_IMPLICIT (old_decl)) warning_at (loc, OPT_Wmissing_declarations, - "%qD was used with no declaration before its definition", decl1); + "%qD was used with no declaration before its definition", decl1); /* This function exists in static storage. (This does not mean `static' in the C sense!) */ @@ -7864,14 +7851,14 @@ if (warn_main && MAIN_NAME_P (DECL_NAME (decl1))) { if (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (decl1))) - != integer_type_node) - pedwarn (loc, OPT_Wmain, "return type of %qD is not %<int%>", decl1); + != integer_type_node) + pedwarn (loc, OPT_Wmain, "return type of %qD is not %<int%>", decl1); check_main_parameter_types (decl1); if (!TREE_PUBLIC (decl1)) - pedwarn (loc, OPT_Wmain, - "%qD is normally a non-static function", decl1); + pedwarn (loc, OPT_Wmain, + "%qD is normally a non-static function", decl1); } /* Record the decl so that the function name is defined. @@ -7908,8 +7895,8 @@ if (current_scope->bindings) { error_at (DECL_SOURCE_LOCATION (fndecl), - "old-style parameter declarations in prototyped " - "function definition"); + "old-style parameter declarations in prototyped " + "function definition"); /* Get rid of the old-style declarations. */ pop_scope (); @@ -7920,9 +7907,9 @@ (this happens when a function definition has just an ellipsis in its parameter list). */ else if (!in_system_header && !current_function_scope - && arg_info->types != error_mark_node) + && arg_info->types != error_mark_node) warning_at (DECL_SOURCE_LOCATION (fndecl), OPT_Wtraditional, - "traditional C rejects ISO C style function definitions"); + "traditional C rejects ISO C style function definitions"); /* Now make all the parameter declarations visible in the function body. We can bypass most of the grunt work of pushdecl. */ @@ -7930,15 +7917,15 @@ { DECL_CONTEXT (decl) = current_function_decl; if (DECL_NAME (decl)) - { - bind (DECL_NAME (decl), decl, current_scope, - /*invisible=*/false, /*nested=*/false, - UNKNOWN_LOCATION); - if (!TREE_USED (decl)) - warn_if_shadowing (decl); - } + { + bind (DECL_NAME (decl), decl, current_scope, + /*invisible=*/false, /*nested=*/false, + UNKNOWN_LOCATION); + if (!TREE_USED (decl)) + warn_if_shadowing (decl); + } else - error_at (DECL_SOURCE_LOCATION (decl), "parameter name omitted"); + error_at (DECL_SOURCE_LOCATION (decl), "parameter name omitted"); } /* Record the parameter list in the function declaration. */ @@ -7975,19 +7962,19 @@ if (!in_system_header) warning_at (DECL_SOURCE_LOCATION (fndecl), - OPT_Wold_style_definition, "old-style function definition"); + OPT_Wold_style_definition, "old-style function definition"); /* Match each formal parameter name with its declaration. Save each decl in the appropriate TREE_PURPOSE slot of the parmids chain. */ for (parm = parmids; parm; parm = TREE_CHAIN (parm)) { if (TREE_VALUE (parm) == 0) - { - error_at (DECL_SOURCE_LOCATION (fndecl), - "parameter name missing from parameter list"); - TREE_PURPOSE (parm) = 0; - continue; - } + { + error_at (DECL_SOURCE_LOCATION (fndecl), + "parameter name missing from parameter list"); + TREE_PURPOSE (parm) = 0; + continue; + } b = I_SYMBOL_BINDING (TREE_VALUE (parm)); if (b && B_IN_CURRENT_SCOPE (b)) @@ -8023,32 +8010,32 @@ } /* If no declaration found, default to int. */ else - { - /* FIXME diagnostics: This should be the location of the argument, - not the FNDECL. E.g., for an old-style declaration - - int f10(v) { blah; } - - We should use the location of the V, not the F10. - Unfortunately, the V is an IDENTIFIER_NODE which has no - location. In the future we need locations for c_arg_info - entries. - - See gcc.dg/Wshadow-3.c for an example of this problem. */ - decl = build_decl (DECL_SOURCE_LOCATION (fndecl), - PARM_DECL, TREE_VALUE (parm), integer_type_node); - DECL_ARG_TYPE (decl) = TREE_TYPE (decl); - pushdecl (decl); - warn_if_shadowing (decl); - - if (flag_isoc99) - pedwarn (DECL_SOURCE_LOCATION (decl), - 0, "type of %qD defaults to %<int%>", decl); - else - warning_at (DECL_SOURCE_LOCATION (decl), - OPT_Wmissing_parameter_type, - "type of %qD defaults to %<int%>", decl); - } + { + /* FIXME diagnostics: This should be the location of the argument, + not the FNDECL. E.g., for an old-style declaration + + int f10(v) { blah; } + + We should use the location of the V, not the F10. + Unfortunately, the V is an IDENTIFIER_NODE which has no + location. In the future we need locations for c_arg_info + entries. + + See gcc.dg/Wshadow-3.c for an example of this problem. */ + decl = build_decl (DECL_SOURCE_LOCATION (fndecl), + PARM_DECL, TREE_VALUE (parm), integer_type_node); + DECL_ARG_TYPE (decl) = TREE_TYPE (decl); + pushdecl (decl); + warn_if_shadowing (decl); + + if (flag_isoc99) + pedwarn (DECL_SOURCE_LOCATION (decl), + 0, "type of %qD defaults to %<int%>", decl); + else + warning_at (DECL_SOURCE_LOCATION (decl), + OPT_Wmissing_parameter_type, + "type of %qD defaults to %<int%>", decl); + } TREE_PURPOSE (parm) = decl; pointer_set_insert (seen_args, decl); @@ -8061,27 +8048,27 @@ { parm = b->decl; if (TREE_CODE (parm) != PARM_DECL) - continue; + continue; if (TREE_TYPE (parm) != error_mark_node - && !COMPLETE_TYPE_P (TREE_TYPE (parm))) - { - error_at (DECL_SOURCE_LOCATION (parm), - "parameter %qD has incomplete type", parm); - TREE_TYPE (parm) = error_mark_node; - } + && !COMPLETE_TYPE_P (TREE_TYPE (parm))) + { + error_at (DECL_SOURCE_LOCATION (parm), + "parameter %qD has incomplete type", parm); + TREE_TYPE (parm) = error_mark_node; + } if (!pointer_set_contains (seen_args, parm)) - { - error_at (DECL_SOURCE_LOCATION (parm), - "declaration for parameter %qD but no such parameter", - parm); - - /* Pretend the parameter was not missing. - This gets us to a standard state and minimizes - further error messages. */ - parmids = chainon (parmids, tree_cons (parm, 0, 0)); - } + { + error_at (DECL_SOURCE_LOCATION (parm), + "declaration for parameter %qD but no such parameter", + parm); + + /* Pretend the parameter was not missing. + This gets us to a standard state and minimizes + further error messages. */ + parmids = chainon (parmids, tree_cons (parm, 0, 0)); + } } /* Chain the declarations together in the order of the list of @@ -8116,8 +8103,8 @@ { tree type; for (parm = DECL_ARGUMENTS (fndecl), - type = current_function_prototype_arg_types; - parm || (type && TREE_VALUE (type) != error_mark_node + type = current_function_prototype_arg_types; + parm || (type && TREE_VALUE (type) != error_mark_node && (TYPE_MAIN_VARIANT (TREE_VALUE (type)) != void_type_node)); parm = DECL_CHAIN (parm), type = TREE_CHAIN (type)) { @@ -8221,17 +8208,17 @@ } type = tree_cons (NULL_TREE, void_type_node, NULL_TREE); if (last) - TREE_CHAIN (last) = type; + TREE_CHAIN (last) = type; else - actual = type; + actual = type; /* We are going to assign a new value for the TYPE_ACTUAL_ARG_TYPES - of the type of this function, but we need to avoid having this - affect the types of other similarly-typed functions, so we must - first force the generation of an identical (but separate) type - node for the relevant function type. The new node we create - will be a variant of the main variant of the original function - type. */ + of the type of this function, but we need to avoid having this + affect the types of other similarly-typed functions, so we must + first force the generation of an identical (but separate) type + node for the relevant function type. The new node we create + will be a variant of the main variant of the original function + type. */ TREE_TYPE (fndecl) = build_variant_type_copy (TREE_TYPE (fndecl)); @@ -8295,7 +8282,7 @@ /* ??? Insert the contents of the pending sizes list into the function to be evaluated. The only reason left to have this is - void foo(int n, int array[n++]) + void foo(int n, int array[n++]) because we throw away the array type in favor of a pointer type, and thus won't naturally see the SAVE_EXPR containing the increment. All other pending sizes would be handled by gimplify_parameters. */ @@ -8356,10 +8343,10 @@ == integer_type_node && flag_isoc99) { /* Hack. We don't want the middle-end to warn that this return - is unreachable, so we mark its location as special. Using - UNKNOWN_LOCATION has the problem that it gets clobbered in - annotate_one_with_locus. A cleaner solution might be to - ensure ! should_carry_locus_p (stmt), but that needs a flag. + is unreachable, so we mark its location as special. Using + UNKNOWN_LOCATION has the problem that it gets clobbered in + annotate_one_with_locus. A cleaner solution might be to + ensure ! should_carry_locus_p (stmt), but that needs a flag. */ c_finish_return (BUILTINS_LOCATION, integer_zero_node, NULL_TREE); } @@ -8386,7 +8373,7 @@ && !TREE_PUBLIC (fndecl)) { warning (OPT_Wreturn_type, - "no return statement in function returning non-void"); + "no return statement in function returning non-void"); TREE_NO_WARNING (fndecl) = 1; } @@ -8429,26 +8416,26 @@ && !undef_nested_function) { if (!decl_function_context (fndecl)) - { - invoke_plugin_callbacks (PLUGIN_PRE_GENERICIZE, fndecl); - c_genericize (fndecl); - - /* ??? Objc emits functions after finalizing the compilation unit. - This should be cleaned up later and this conditional removed. */ - if (cgraph_global_info_ready) - { - cgraph_add_new_function (fndecl, false); - return; - } - cgraph_finalize_function (fndecl, false); - } + { + invoke_plugin_callbacks (PLUGIN_PRE_GENERICIZE, fndecl); + c_genericize (fndecl); + + /* ??? Objc emits functions after finalizing the compilation unit. + This should be cleaned up later and this conditional removed. */ + if (cgraph_global_info_ready) + { + cgraph_add_new_function (fndecl, false); + return; + } + cgraph_finalize_function (fndecl, false); + } else - { - /* Register this function with cgraph just far enough to get it - added to our parent's nested function list. Handy, since the - C front end doesn't have such a list. */ - (void) cgraph_node (fndecl); - } + { + /* Register this function with cgraph just far enough to get it + added to our parent's nested function list. Handy, since the + C front end doesn't have such a list. */ + (void) cgraph_node (fndecl); + } } if (!decl_function_context (fndecl)) @@ -8483,16 +8470,16 @@ { static bool hint = true; /* If we get here, declarations have been used in a for loop without - the C99 for loop scope. This doesn't make much sense, so don't - allow it. */ + the C99 for loop scope. This doesn't make much sense, so don't + allow it. */ error_at (loc, "%<for%> loop initial declarations " - "are only allowed in C99 mode"); + "are only allowed in C99 mode"); if (hint) - { - inform (loc, - "use option -std=c99 or -std=gnu99 to compile your code"); - hint = false; - } + { + inform (loc, + "use option -std=c99 or -std=gnu99 to compile your code"); + hint = false; + } return NULL_TREE; } /* C99 subclause 6.8.5 paragraph 3: @@ -8515,42 +8502,42 @@ tree decl = b->decl; if (!id) - continue; + continue; switch (TREE_CODE (decl)) - { - case VAR_DECL: - { - location_t decl_loc = DECL_SOURCE_LOCATION (decl); - if (TREE_STATIC (decl)) - error_at (decl_loc, - "declaration of static variable %qD in %<for%> loop " - "initial declaration", decl); - else if (DECL_EXTERNAL (decl)) - error_at (decl_loc, - "declaration of %<extern%> variable %qD in %<for%> loop " - "initial declaration", decl); - } - break; - - case RECORD_TYPE: - error_at (loc, - "%<struct %E%> declared in %<for%> loop initial " - "declaration", id); - break; - case UNION_TYPE: - error_at (loc, - "%<union %E%> declared in %<for%> loop initial declaration", - id); - break; - case ENUMERAL_TYPE: - error_at (loc, "%<enum %E%> declared in %<for%> loop " - "initial declaration", id); - break; - default: - error_at (loc, "declaration of non-variable " - "%qD in %<for%> loop initial declaration", decl); - } + { + case VAR_DECL: + { + location_t decl_loc = DECL_SOURCE_LOCATION (decl); + if (TREE_STATIC (decl)) + error_at (decl_loc, + "declaration of static variable %qD in %<for%> loop " + "initial declaration", decl); + else if (DECL_EXTERNAL (decl)) + error_at (decl_loc, + "declaration of %<extern%> variable %qD in %<for%> loop " + "initial declaration", decl); + } + break; + + case RECORD_TYPE: + error_at (loc, + "%<struct %E%> declared in %<for%> loop initial " + "declaration", id); + break; + case UNION_TYPE: + error_at (loc, + "%<union %E%> declared in %<for%> loop initial declaration", + id); + break; + case ENUMERAL_TYPE: + error_at (loc, "%<enum %E%> declared in %<for%> loop " + "initial declaration", id); + break; + default: + error_at (loc, "declaration of non-variable " + "%qD in %<for%> loop initial declaration", decl); + } n_decls++; one_decl = decl; @@ -8598,7 +8585,7 @@ { /* Stop pointing to the local nodes about to be freed. */ /* But DECL_INITIAL must remain nonzero so we know this - was an actual function definition. */ + was an actual function definition. */ DECL_INITIAL (current_function_decl) = error_mark_node; DECL_ARGUMENTS (current_function_decl) = 0; } @@ -8632,7 +8619,7 @@ /* Return the global value of T as a symbol. */ tree -identifier_global_value (tree t) +identifier_global_value (tree t) { struct c_binding *b; @@ -8672,7 +8659,7 @@ struct c_parm * build_c_parm (struct c_declspecs *specs, tree attrs, - struct c_declarator *declarator) + struct c_declarator *declarator) { struct c_parm *ret = XOBNEW (&parser_obstack, struct c_parm); ret->specs = specs; @@ -8700,7 +8687,7 @@ struct c_declarator * build_function_declarator (struct c_arg_info *args, - struct c_declarator *target) + struct c_declarator *target) { struct c_declarator *ret = XOBNEW (&parser_obstack, struct c_declarator); ret->kind = cdk_function; @@ -8731,7 +8718,7 @@ struct c_declarator * make_pointer_declarator (struct c_declspecs *type_quals_attrs, - struct c_declarator *target) + struct c_declarator *target) { tree attrs; int quals = 0; @@ -8742,7 +8729,7 @@ attrs = type_quals_attrs->attrs; quals = quals_from_declspecs (type_quals_attrs); if (attrs != NULL_TREE) - itarget = build_attrs_declarator (attrs, target); + itarget = build_attrs_declarator (attrs, target); } ret->kind = cdk_pointer; ret->declarator = itarget; @@ -8799,8 +8786,8 @@ if (!ADDR_SPACE_GENERIC_P (specs->address_space) && specs->address_space != as) error ("incompatible address space qualifiers %qs and %qs", - c_addr_space_name (as), - c_addr_space_name (specs->address_space)); + c_addr_space_name (as), + c_addr_space_name (specs->address_space)); else specs->address_space = as; return specs; @@ -8817,7 +8804,7 @@ specs->non_sc_seen_p = true; specs->declspecs_seen_p = true; gcc_assert (TREE_CODE (qual) == IDENTIFIER_NODE - && C_IS_RESERVED_WORD (qual)); + && C_IS_RESERVED_WORD (qual)); i = C_RID_CODE (qual); switch (i) { @@ -8846,7 +8833,7 @@ struct c_declspecs * declspecs_add_type (location_t loc, struct c_declspecs *specs, - struct c_typespec spec) + struct c_typespec spec) { tree type = spec.spec; specs->non_sc_seen_p = true; @@ -8862,10 +8849,10 @@ { enum rid i = C_RID_CODE (type); if (specs->type) - { - error_at (loc, "two or more data types in declaration specifiers"); - return specs; - } + { + error_at (loc, "two or more data types in declaration specifiers"); + return specs; + } if ((int) i <= (int) RID_LAST_MODIFIER) { /* "long", "short", "signed", "unsigned", "_Complex" or "_Sat". */ @@ -8901,10 +8888,10 @@ ("both %<long%> and %<void%> in " "declaration specifiers")); #ifndef noCbC - else if (specs->typespec_word == cts_CbC_code) - error_at (loc, - ("both %<long%> and %<void%> in " - "declaration specifiers")); + else if (specs->typespec_word == cts_CbC_code) + error_at (loc, + ("both %<long%> and %<void%> in " + "declaration specifiers")); #endif else if (specs->typespec_word == cts_int128) error_at (loc, @@ -8948,10 +8935,10 @@ ("both %<short%> and %<void%> in " "declaration specifiers")); #ifndef noCbC - else if (specs->typespec_word == cts_CbC_code) - error_at (loc, - ("both %<short%> and %<void%> in " - "declaration specifiers")); + else if (specs->typespec_word == cts_CbC_code) + error_at (loc, + ("both %<short%> and %<void%> in " + "declaration specifiers")); #endif else if (specs->typespec_word == cts_int128) error_at (loc, @@ -8974,126 +8961,125 @@ ("both %<short%> and %<double%> in " "declaration specifiers")); else if (specs->typespec_word == cts_dfloat32) ->>>>>>> other error_at (loc, - ("both %<short%> and %<_Decimal32%> in " - "declaration specifiers")); - else if (specs->typespec_word == cts_dfloat64) - error_at (loc, - ("both %<short%> and %<_Decimal64%> in " - "declaration specifiers")); - else if (specs->typespec_word == cts_dfloat128) - error_at (loc, - ("both %<short%> and %<_Decimal128%> in " - "declaration specifiers")); - else - specs->short_p = true; - break; - case RID_SIGNED: - dupe = specs->signed_p; - if (specs->unsigned_p) - error_at (loc, - ("both %<signed%> and %<unsigned%> in " - "declaration specifiers")); - else if (specs->typespec_word == cts_void) - error_at (loc, - ("both %<signed%> and %<void%> in " - "declaration specifiers")); + ("both %<short%> and %<_Decimal32%> in " + "declaration specifiers")); + else if (specs->typespec_word == cts_dfloat64) + error_at (loc, + ("both %<short%> and %<_Decimal64%> in " + "declaration specifiers")); + else if (specs->typespec_word == cts_dfloat128) + error_at (loc, + ("both %<short%> and %<_Decimal128%> in " + "declaration specifiers")); + else + specs->short_p = true; + break; + case RID_SIGNED: + dupe = specs->signed_p; + if (specs->unsigned_p) + error_at (loc, + ("both %<signed%> and %<unsigned%> in " + "declaration specifiers")); + else if (specs->typespec_word == cts_void) + error_at (loc, + ("both %<signed%> and %<void%> in " + "declaration specifiers")); #ifndef noCbC else if (specs->typespec_word == cts_CbC_code) error_at (loc, ("both %<signed%> and %<void%> in " "declaration specifiers")); #endif - else if (specs->typespec_word == cts_bool) - error_at (loc, - ("both %<signed%> and %<_Bool%> in " - "declaration specifiers")); - else if (specs->typespec_word == cts_float) - error_at (loc, - ("both %<signed%> and %<float%> in " - "declaration specifiers")); - else if (specs->typespec_word == cts_double) - error_at (loc, - ("both %<signed%> and %<double%> in " - "declaration specifiers")); - else if (specs->typespec_word == cts_dfloat32) - error_at (loc, - ("both %<signed%> and %<_Decimal32%> in " - "declaration specifiers")); - else if (specs->typespec_word == cts_dfloat64) - error_at (loc, - ("both %<signed%> and %<_Decimal64%> in " - "declaration specifiers")); - else if (specs->typespec_word == cts_dfloat128) - error_at (loc, - ("both %<signed%> and %<_Decimal128%> in " - "declaration specifiers")); - else - specs->signed_p = true; - break; - case RID_UNSIGNED: - dupe = specs->unsigned_p; - if (specs->signed_p) - error_at (loc, - ("both %<signed%> and %<unsigned%> in " - "declaration specifiers")); - else if (specs->typespec_word == cts_void) - error_at (loc, - ("both %<unsigned%> and %<void%> in " - "declaration specifiers")); + else if (specs->typespec_word == cts_bool) + error_at (loc, + ("both %<signed%> and %<_Bool%> in " + "declaration specifiers")); + else if (specs->typespec_word == cts_float) + error_at (loc, + ("both %<signed%> and %<float%> in " + "declaration specifiers")); + else if (specs->typespec_word == cts_double) + error_at (loc, + ("both %<signed%> and %<double%> in " + "declaration specifiers")); + else if (specs->typespec_word == cts_dfloat32) + error_at (loc, + ("both %<signed%> and %<_Decimal32%> in " + "declaration specifiers")); + else if (specs->typespec_word == cts_dfloat64) + error_at (loc, + ("both %<signed%> and %<_Decimal64%> in " + "declaration specifiers")); + else if (specs->typespec_word == cts_dfloat128) + error_at (loc, + ("both %<signed%> and %<_Decimal128%> in " + "declaration specifiers")); + else + specs->signed_p = true; + break; + case RID_UNSIGNED: + dupe = specs->unsigned_p; + if (specs->signed_p) + error_at (loc, + ("both %<signed%> and %<unsigned%> in " + "declaration specifiers")); + else if (specs->typespec_word == cts_void) + error_at (loc, + ("both %<unsigned%> and %<void%> in " + "declaration specifiers")); #ifndef noCbC else if (specs->typespec_word == cts_CbC_code) error_at (loc, ("both %<unsigned%> and %<void%> in " "declaration specifiers")); #endif - else if (specs->typespec_word == cts_bool) - error_at (loc, - ("both %<unsigned%> and %<_Bool%> in " - "declaration specifiers")); - else if (specs->typespec_word == cts_float) - error_at (loc, - ("both %<unsigned%> and %<float%> in " - "declaration specifiers")); - else if (specs->typespec_word == cts_double) - error_at (loc, - ("both %<unsigned%> and %<double%> in " - "declaration specifiers")); + else if (specs->typespec_word == cts_bool) + error_at (loc, + ("both %<unsigned%> and %<_Bool%> in " + "declaration specifiers")); + else if (specs->typespec_word == cts_float) + error_at (loc, + ("both %<unsigned%> and %<float%> in " + "declaration specifiers")); + else if (specs->typespec_word == cts_double) + error_at (loc, + ("both %<unsigned%> and %<double%> in " + "declaration specifiers")); else if (specs->typespec_word == cts_dfloat32) - error_at (loc, - ("both %<unsigned%> and %<_Decimal32%> in " - "declaration specifiers")); - else if (specs->typespec_word == cts_dfloat64) - error_at (loc, - ("both %<unsigned%> and %<_Decimal64%> in " - "declaration specifiers")); - else if (specs->typespec_word == cts_dfloat128) - error_at (loc, - ("both %<unsigned%> and %<_Decimal128%> in " - "declaration specifiers")); - else - specs->unsigned_p = true; - break; - case RID_COMPLEX: - dupe = specs->complex_p; - if (!flag_isoc99 && !in_system_header) - pedwarn (loc, OPT_pedantic, - "ISO C90 does not support complex types"); - if (specs->typespec_word == cts_void) - error_at (loc, - ("both %<complex%> and %<void%> in " - "declaration specifiers")); + error_at (loc, + ("both %<unsigned%> and %<_Decimal32%> in " + "declaration specifiers")); + else if (specs->typespec_word == cts_dfloat64) + error_at (loc, + ("both %<unsigned%> and %<_Decimal64%> in " + "declaration specifiers")); + else if (specs->typespec_word == cts_dfloat128) + error_at (loc, + ("both %<unsigned%> and %<_Decimal128%> in " + "declaration specifiers")); + else + specs->unsigned_p = true; + break; + case RID_COMPLEX: + dupe = specs->complex_p; + if (!flag_isoc99 && !in_system_header) + pedwarn (loc, OPT_pedantic, + "ISO C90 does not support complex types"); + if (specs->typespec_word == cts_void) + error_at (loc, + ("both %<complex%> and %<void%> in " + "declaration specifiers")); #ifndef noCbC else if (specs->typespec_word == cts_CbC_code) error_at (loc, ("both %<complex%> and %<void%> in " "declaration specifiers")); #endif - else if (specs->typespec_word == cts_bool) - error_at (loc, - ("both %<complex%> and %<_Bool%> in " - "declaration specifiers")); + else if (specs->typespec_word == cts_bool) + error_at (loc, + ("both %<complex%> and %<_Bool%> in " + "declaration specifiers")); else if (specs->typespec_word == cts_dfloat32) error_at (loc, ("both %<complex%> and %<_Decimal32%> in " @@ -9156,33 +9142,33 @@ ("both %<_Sat%> and %<double%> in " "declaration specifiers")); else if (specs->typespec_word == cts_dfloat32) - error_at (loc, - ("both %<_Sat%> and %<_Decimal32%> in " - "declaration specifiers")); - else if (specs->typespec_word == cts_dfloat64) - error_at (loc, - ("both %<_Sat%> and %<_Decimal64%> in " - "declaration specifiers")); - else if (specs->typespec_word == cts_dfloat128) - error_at (loc, - ("both %<_Sat%> and %<_Decimal128%> in " - "declaration specifiers")); - else if (specs->complex_p) - error_at (loc, - ("both %<_Sat%> and %<complex%> in " - "declaration specifiers")); - else - specs->saturating_p = true; - break; - default: - gcc_unreachable (); - } - - if (dupe) - error_at (loc, "duplicate %qE", type); - - return specs; - } + error_at (loc, + ("both %<_Sat%> and %<_Decimal32%> in " + "declaration specifiers")); + else if (specs->typespec_word == cts_dfloat64) + error_at (loc, + ("both %<_Sat%> and %<_Decimal64%> in " + "declaration specifiers")); + else if (specs->typespec_word == cts_dfloat128) + error_at (loc, + ("both %<_Sat%> and %<_Decimal128%> in " + "declaration specifiers")); + else if (specs->complex_p) + error_at (loc, + ("both %<_Sat%> and %<complex%> in " + "declaration specifiers")); + else + specs->saturating_p = true; + break; + default: + gcc_unreachable (); + } + + if (dupe) + error_at (loc, "duplicate %qE", type); + + return specs; + } else { /* "void", "_Bool", "char", "int", "float", "double", "_Decimal32", @@ -9249,25 +9235,25 @@ specs->typespec_word = cts_void; return specs; #ifndef noCbC - case RID_CbC_CODE: - if (specs->long_p) - error ("both %<long%> and %<void%> in " - "declaration specifiers"); - else if (specs->short_p) - error ("both %<short%> and %<void%> in " - "declaration specifiers"); - else if (specs->signed_p) - error ("both %<signed%> and %<void%> in " - "declaration specifiers"); - else if (specs->unsigned_p) - error ("both %<unsigned%> and %<void%> in " - "declaration specifiers"); - else if (specs->complex_p) - error ("both %<complex%> and %<void%> in " - "declaration specifiers"); - else - specs->typespec_word = cts_CbC_code; - return specs; + case RID_CbC_CODE: + if (specs->long_p) + error ("both %<long%> and %<void%> in " + "declaration specifiers"); + else if (specs->short_p) + error ("both %<short%> and %<void%> in " + "declaration specifiers"); + else if (specs->signed_p) + error ("both %<signed%> and %<void%> in " + "declaration specifiers"); + else if (specs->unsigned_p) + error ("both %<unsigned%> and %<void%> in " + "declaration specifiers"); + else if (specs->complex_p) + error ("both %<complex%> and %<void%> in " + "declaration specifiers"); + else + specs->typespec_word = cts_CbC_code; + return specs; #endif case RID_BOOL: if (specs->long_p) @@ -9407,57 +9393,57 @@ str); else if (specs->complex_p) error_at (loc, - ("both %<complex%> and %<%s%> in " - "declaration specifiers"), - str); + ("both %<complex%> and %<%s%> in " + "declaration specifiers"), + str); else if (specs->saturating_p) error_at (loc, - ("both %<_Sat%> and %<%s%> in " - "declaration specifiers"), - str); - else if (i == RID_DFLOAT32) - specs->typespec_word = cts_dfloat32; - else if (i == RID_DFLOAT64) - specs->typespec_word = cts_dfloat64; - else - specs->typespec_word = cts_dfloat128; - } - if (!targetm.decimal_float_supported_p ()) - error_at (loc, - ("decimal floating point not supported " - "for this target")); - pedwarn (loc, OPT_pedantic, - "ISO C does not support decimal floating point"); - return specs; - case RID_FRACT: - case RID_ACCUM: - { - const char *str; - if (i == RID_FRACT) - str = "_Fract"; - else - str = "_Accum"; + ("both %<_Sat%> and %<%s%> in " + "declaration specifiers"), + str); + else if (i == RID_DFLOAT32) + specs->typespec_word = cts_dfloat32; + else if (i == RID_DFLOAT64) + specs->typespec_word = cts_dfloat64; + else + specs->typespec_word = cts_dfloat128; + } + if (!targetm.decimal_float_supported_p ()) + error_at (loc, + ("decimal floating point not supported " + "for this target")); + pedwarn (loc, OPT_pedantic, + "ISO C does not support decimal floating point"); + return specs; + case RID_FRACT: + case RID_ACCUM: + { + const char *str; + if (i == RID_FRACT) + str = "_Fract"; + else + str = "_Accum"; if (specs->complex_p) error_at (loc, - ("both %<complex%> and %<%s%> in " - "declaration specifiers"), - str); - else if (i == RID_FRACT) - specs->typespec_word = cts_fract; - else - specs->typespec_word = cts_accum; - } - if (!targetm.fixed_point_supported_p ()) - error_at (loc, - "fixed-point types not supported for this target"); - pedwarn (loc, OPT_pedantic, - "ISO C does not support fixed-point types"); - return specs; - default: - /* ObjC reserved word "id", handled below. */ - break; - } - } + ("both %<complex%> and %<%s%> in " + "declaration specifiers"), + str); + else if (i == RID_FRACT) + specs->typespec_word = cts_fract; + else + specs->typespec_word = cts_accum; + } + if (!targetm.fixed_point_supported_p ()) + error_at (loc, + "fixed-point types not supported for this target"); + pedwarn (loc, OPT_pedantic, + "ISO C does not support fixed-point types"); + return specs; + default: + /* ObjC reserved word "id", handled below. */ + break; + } + } } /* Now we have a typedef (a TYPE_DECL node), an identifier (some @@ -9472,37 +9458,37 @@ else if (TREE_CODE (type) == TYPE_DECL) { if (TREE_TYPE (type) == error_mark_node) - ; /* Allow the type to default to int to avoid cascading errors. */ + ; /* Allow the type to default to int to avoid cascading errors. */ else - { - specs->type = TREE_TYPE (type); - specs->decl_attr = DECL_ATTRIBUTES (type); - specs->typedef_p = true; - specs->explicit_signed_p = C_TYPEDEF_EXPLICITLY_SIGNED (type); - - /* If this typedef name is defined in a struct, then a C++ - lookup would return a different value. */ - if (warn_cxx_compat - && I_SYMBOL_BINDING (DECL_NAME (type))->in_struct) - warning_at (loc, OPT_Wc___compat, - "C++ lookup of %qD would return a field, not a type", - type); - - /* If we are parsing a struct, record that a struct field - used a typedef. */ - if (warn_cxx_compat && struct_parse_info != NULL) - VEC_safe_push (tree, heap, struct_parse_info->typedefs_seen, type); - } + { + specs->type = TREE_TYPE (type); + specs->decl_attr = DECL_ATTRIBUTES (type); + specs->typedef_p = true; + specs->explicit_signed_p = C_TYPEDEF_EXPLICITLY_SIGNED (type); + + /* If this typedef name is defined in a struct, then a C++ + lookup would return a different value. */ + if (warn_cxx_compat + && I_SYMBOL_BINDING (DECL_NAME (type))->in_struct) + warning_at (loc, OPT_Wc___compat, + "C++ lookup of %qD would return a field, not a type", + type); + + /* If we are parsing a struct, record that a struct field + used a typedef. */ + if (warn_cxx_compat && struct_parse_info != NULL) + VEC_safe_push (tree, heap, struct_parse_info->typedefs_seen, type); + } } else if (TREE_CODE (type) == IDENTIFIER_NODE) { tree t = lookup_name (type); if (!t || TREE_CODE (t) != TYPE_DECL) - error_at (loc, "%qE fails to be a typedef or built in type", type); + error_at (loc, "%qE fails to be a typedef or built in type", type); else if (TREE_TYPE (t) == error_mark_node) - ; + ; else - specs->type = TREE_TYPE (t); + specs->type = TREE_TYPE (t); } else { @@ -9536,7 +9522,7 @@ bool dupe = false; specs->declspecs_seen_p = true; gcc_assert (TREE_CODE (scspec) == IDENTIFIER_NODE - && C_IS_RESERVED_WORD (scspec)); + && C_IS_RESERVED_WORD (scspec)); i = C_RID_CODE (scspec); if (specs->non_sc_seen_p) warning (OPT_Wold_style_declaration, @@ -9545,22 +9531,22 @@ { case RID_INLINE: /* C99 permits duplicate inline. Although of doubtful utility, - it seems simplest to permit it in gnu89 mode as well, as - there is also little utility in maintaining this as a - difference between gnu89 and C99 inline. */ + it seems simplest to permit it in gnu89 mode as well, as + there is also little utility in maintaining this as a + difference between gnu89 and C99 inline. */ dupe = false; specs->inline_p = true; break; case RID_THREAD: dupe = specs->thread_p; if (specs->storage_class == csc_auto) - error ("%<__thread%> used with %<auto%>"); + error ("%<__thread%> used with %<auto%>"); else if (specs->storage_class == csc_register) - error ("%<__thread%> used with %<register%>"); + error ("%<__thread%> used with %<register%>"); else if (specs->storage_class == csc_typedef) - error ("%<__thread%> used with %<typedef%>"); + error ("%<__thread%> used with %<typedef%>"); else - specs->thread_p = true; + specs->thread_p = true; break; case RID_AUTO: n = csc_auto; @@ -9569,7 +9555,7 @@ n = csc_extern; /* Diagnose "__thread extern". */ if (specs->thread_p) - error ("%<__thread%> before %<extern%>"); + error ("%<__thread%> before %<extern%>"); break; case RID_REGISTER: n = csc_register; @@ -9578,7 +9564,7 @@ n = csc_static; /* Diagnose "__thread static". */ if (specs->thread_p) - error ("%<__thread%> before %<static%>"); + error ("%<__thread%> before %<static%>"); break; case RID_TYPEDEF: n = csc_typedef; @@ -9593,18 +9579,18 @@ if (n != csc_none) { if (specs->storage_class != csc_none && n != specs->storage_class) - { - error ("multiple storage classes in declaration specifiers"); - } + { + error ("multiple storage classes in declaration specifiers"); + } else - { - specs->storage_class = n; - if (n != csc_extern && n != csc_static && specs->thread_p) - { - error ("%<__thread%> used with %qE", scspec); - specs->thread_p = false; - } - } + { + specs->storage_class = n; + if (n != csc_extern && n != csc_static && specs->thread_p) + { + error ("%<__thread%> used with %qE", scspec); + specs->thread_p = false; + } + } } return specs; } @@ -9651,32 +9637,32 @@ if (specs->typespec_word == cts_none) { if (specs->saturating_p) - { - error ("%<_Sat%> is used without %<_Fract%> or %<_Accum%>"); - if (!targetm.fixed_point_supported_p ()) - error ("fixed-point types not supported for this target"); - specs->typespec_word = cts_fract; - } + { + error ("%<_Sat%> is used without %<_Fract%> or %<_Accum%>"); + if (!targetm.fixed_point_supported_p ()) + error ("fixed-point types not supported for this target"); + specs->typespec_word = cts_fract; + } else if (specs->long_p || specs->short_p - || specs->signed_p || specs->unsigned_p) - { - specs->typespec_word = cts_int; - } + || specs->signed_p || specs->unsigned_p) + { + specs->typespec_word = cts_int; + } else if (specs->complex_p) - { - specs->typespec_word = cts_double; - pedwarn (input_location, OPT_pedantic, - "ISO C does not support plain %<complex%> meaning " - "%<double complex%>"); - } + { + specs->typespec_word = cts_double; + pedwarn (input_location, OPT_pedantic, + "ISO C does not support plain %<complex%> meaning " + "%<double complex%>"); + } else - { - specs->typespec_word = cts_int; - specs->default_int_p = true; - /* We don't diagnose this here because grokdeclarator will - give more specific diagnostics according to whether it is - a function definition. */ - } + { + specs->typespec_word = cts_int; + specs->default_int_p = true; + /* We don't diagnose this here because grokdeclarator will + give more specific diagnostics according to whether it is + a function definition. */ + } } /* If "signed" was specified, record this to distinguish "int" and @@ -9692,31 +9678,31 @@ case cts_CbC_code: #endif gcc_assert (!specs->long_p && !specs->short_p - && !specs->signed_p && !specs->unsigned_p - && !specs->complex_p); + && !specs->signed_p && !specs->unsigned_p + && !specs->complex_p); specs->type = void_type_node; break; case cts_bool: gcc_assert (!specs->long_p && !specs->short_p - && !specs->signed_p && !specs->unsigned_p - && !specs->complex_p); + && !specs->signed_p && !specs->unsigned_p + && !specs->complex_p); specs->type = boolean_type_node; break; case cts_char: gcc_assert (!specs->long_p && !specs->short_p); gcc_assert (!(specs->signed_p && specs->unsigned_p)); if (specs->signed_p) - specs->type = signed_char_type_node; + specs->type = signed_char_type_node; else if (specs->unsigned_p) - specs->type = unsigned_char_type_node; + specs->type = unsigned_char_type_node; else - specs->type = char_type_node; + specs->type = char_type_node; if (specs->complex_p) - { - pedwarn (input_location, OPT_pedantic, - "ISO C does not support complex integer types"); - specs->type = build_complex_type (specs->type); - } + { + pedwarn (input_location, OPT_pedantic, + "ISO C does not support complex integer types"); + specs->type = build_complex_type (specs->type); + } break; case cts_int128: gcc_assert (!specs->long_p && !specs->short_p && !specs->long_long_p); @@ -9735,148 +9721,148 @@ gcc_assert (!(specs->long_p && specs->short_p)); gcc_assert (!(specs->signed_p && specs->unsigned_p)); if (specs->long_long_p) - specs->type = (specs->unsigned_p - ? long_long_unsigned_type_node - : long_long_integer_type_node); + specs->type = (specs->unsigned_p + ? long_long_unsigned_type_node + : long_long_integer_type_node); else if (specs->long_p) - specs->type = (specs->unsigned_p - ? long_unsigned_type_node - : long_integer_type_node); + specs->type = (specs->unsigned_p + ? long_unsigned_type_node + : long_integer_type_node); else if (specs->short_p) - specs->type = (specs->unsigned_p - ? short_unsigned_type_node - : short_integer_type_node); + specs->type = (specs->unsigned_p + ? short_unsigned_type_node + : short_integer_type_node); else - specs->type = (specs->unsigned_p - ? unsigned_type_node - : integer_type_node); + specs->type = (specs->unsigned_p + ? unsigned_type_node + : integer_type_node); if (specs->complex_p) - { - pedwarn (input_location, OPT_pedantic, - "ISO C does not support complex integer types"); - specs->type = build_complex_type (specs->type); - } + { + pedwarn (input_location, OPT_pedantic, + "ISO C does not support complex integer types"); + specs->type = build_complex_type (specs->type); + } break; case cts_float: gcc_assert (!specs->long_p && !specs->short_p - && !specs->signed_p && !specs->unsigned_p); + && !specs->signed_p && !specs->unsigned_p); specs->type = (specs->complex_p - ? complex_float_type_node - : float_type_node); + ? complex_float_type_node + : float_type_node); break; case cts_double: gcc_assert (!specs->long_long_p && !specs->short_p - && !specs->signed_p && !specs->unsigned_p); + && !specs->signed_p && !specs->unsigned_p); if (specs->long_p) - { - specs->type = (specs->complex_p - ? complex_long_double_type_node - : long_double_type_node); - } + { + specs->type = (specs->complex_p + ? complex_long_double_type_node + : long_double_type_node); + } else - { - specs->type = (specs->complex_p - ? complex_double_type_node - : double_type_node); - } + { + specs->type = (specs->complex_p + ? complex_double_type_node + : double_type_node); + } break; case cts_dfloat32: case cts_dfloat64: case cts_dfloat128: gcc_assert (!specs->long_p && !specs->long_long_p && !specs->short_p - && !specs->signed_p && !specs->unsigned_p && !specs->complex_p); + && !specs->signed_p && !specs->unsigned_p && !specs->complex_p); if (specs->typespec_word == cts_dfloat32) - specs->type = dfloat32_type_node; + specs->type = dfloat32_type_node; else if (specs->typespec_word == cts_dfloat64) - specs->type = dfloat64_type_node; + specs->type = dfloat64_type_node; else - specs->type = dfloat128_type_node; + specs->type = dfloat128_type_node; break; case cts_fract: gcc_assert (!specs->complex_p); if (!targetm.fixed_point_supported_p ()) - specs->type = integer_type_node; + specs->type = integer_type_node; else if (specs->saturating_p) - { - if (specs->long_long_p) - specs->type = specs->unsigned_p - ? sat_unsigned_long_long_fract_type_node - : sat_long_long_fract_type_node; - else if (specs->long_p) - specs->type = specs->unsigned_p - ? sat_unsigned_long_fract_type_node - : sat_long_fract_type_node; - else if (specs->short_p) - specs->type = specs->unsigned_p - ? sat_unsigned_short_fract_type_node - : sat_short_fract_type_node; + { + if (specs->long_long_p) + specs->type = specs->unsigned_p + ? sat_unsigned_long_long_fract_type_node + : sat_long_long_fract_type_node; + else if (specs->long_p) + specs->type = specs->unsigned_p + ? sat_unsigned_long_fract_type_node + : sat_long_fract_type_node; + else if (specs->short_p) + specs->type = specs->unsigned_p + ? sat_unsigned_short_fract_type_node + : sat_short_fract_type_node; + else + specs->type = specs->unsigned_p + ? sat_unsigned_fract_type_node + : sat_fract_type_node; + } else - specs->type = specs->unsigned_p - ? sat_unsigned_fract_type_node - : sat_fract_type_node; - } - else - { - if (specs->long_long_p) - specs->type = specs->unsigned_p - ? unsigned_long_long_fract_type_node - : long_long_fract_type_node; - else if (specs->long_p) - specs->type = specs->unsigned_p - ? unsigned_long_fract_type_node - : long_fract_type_node; - else if (specs->short_p) - specs->type = specs->unsigned_p - ? unsigned_short_fract_type_node - : short_fract_type_node; - else - specs->type = specs->unsigned_p - ? unsigned_fract_type_node - : fract_type_node; - } + { + if (specs->long_long_p) + specs->type = specs->unsigned_p + ? unsigned_long_long_fract_type_node + : long_long_fract_type_node; + else if (specs->long_p) + specs->type = specs->unsigned_p + ? unsigned_long_fract_type_node + : long_fract_type_node; + else if (specs->short_p) + specs->type = specs->unsigned_p + ? unsigned_short_fract_type_node + : short_fract_type_node; + else + specs->type = specs->unsigned_p + ? unsigned_fract_type_node + : fract_type_node; + } break; case cts_accum: gcc_assert (!specs->complex_p); if (!targetm.fixed_point_supported_p ()) - specs->type = integer_type_node; + specs->type = integer_type_node; else if (specs->saturating_p) - { - if (specs->long_long_p) - specs->type = specs->unsigned_p - ? sat_unsigned_long_long_accum_type_node - : sat_long_long_accum_type_node; - else if (specs->long_p) - specs->type = specs->unsigned_p - ? sat_unsigned_long_accum_type_node - : sat_long_accum_type_node; - else if (specs->short_p) - specs->type = specs->unsigned_p - ? sat_unsigned_short_accum_type_node - : sat_short_accum_type_node; + { + if (specs->long_long_p) + specs->type = specs->unsigned_p + ? sat_unsigned_long_long_accum_type_node + : sat_long_long_accum_type_node; + else if (specs->long_p) + specs->type = specs->unsigned_p + ? sat_unsigned_long_accum_type_node + : sat_long_accum_type_node; + else if (specs->short_p) + specs->type = specs->unsigned_p + ? sat_unsigned_short_accum_type_node + : sat_short_accum_type_node; + else + specs->type = specs->unsigned_p + ? sat_unsigned_accum_type_node + : sat_accum_type_node; + } else - specs->type = specs->unsigned_p - ? sat_unsigned_accum_type_node - : sat_accum_type_node; - } - else - { - if (specs->long_long_p) - specs->type = specs->unsigned_p - ? unsigned_long_long_accum_type_node - : long_long_accum_type_node; - else if (specs->long_p) - specs->type = specs->unsigned_p - ? unsigned_long_accum_type_node - : long_accum_type_node; - else if (specs->short_p) - specs->type = specs->unsigned_p - ? unsigned_short_accum_type_node - : short_accum_type_node; - else - specs->type = specs->unsigned_p - ? unsigned_accum_type_node - : accum_type_node; - } + { + if (specs->long_long_p) + specs->type = specs->unsigned_p + ? unsigned_long_long_accum_type_node + : long_long_accum_type_node; + else if (specs->long_p) + specs->type = specs->unsigned_p + ? unsigned_long_accum_type_node + : long_accum_type_node; + else if (specs->short_p) + specs->type = specs->unsigned_p + ? unsigned_short_accum_type_node + : short_accum_type_node; + else + specs->type = specs->unsigned_p + ? unsigned_accum_type_node + : accum_type_node; + } break; default: gcc_unreachable (); @@ -9899,17 +9885,17 @@ for (decl = globals; decl; decl = DECL_CHAIN (decl)) { /* Check for used but undefined static functions using the C - standard's definition of "used", and set TREE_NO_WARNING so - that check_global_declarations doesn't repeat the check. */ + standard's definition of "used", and set TREE_NO_WARNING so + that check_global_declarations doesn't repeat the check. */ if (TREE_CODE (decl) == FUNCTION_DECL - && DECL_INITIAL (decl) == 0 - && DECL_EXTERNAL (decl) - && !TREE_PUBLIC (decl) - && C_DECL_USED (decl)) - { - pedwarn (input_location, 0, "%q+F used but never defined", decl); - TREE_NO_WARNING (decl) = 1; - } + && DECL_INITIAL (decl) == 0 + && DECL_EXTERNAL (decl) + && !TREE_PUBLIC (decl) + && C_DECL_USED (decl)) + { + pedwarn (input_location, 0, "%q+F used but never defined", decl); + TREE_NO_WARNING (decl) = 1; + } wrapup_global_declaration_1 (decl); } @@ -10019,10 +10005,10 @@ int flags; FILE * stream = dump_begin (TDI_tu, &flags); if (stream && tmp) - { - dump_node (tmp, flags & ~TDF_SLIM, stream); - dump_end (TDI_tu, stream); - } + { + dump_node (tmp, flags & ~TDF_SLIM, stream); + dump_end (TDI_tu, stream); + } } /* Process all file scopes in this compilation, and the external_scope,