diff options
Diffstat (limited to 'gcc/c/c-decl.c')
-rw-r--r-- | gcc/c/c-decl.c | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 1bbccdd..9524977 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -1571,6 +1571,7 @@ pushtag (location_t loc, tree name, tree type) && (TYPE_MAIN_VARIANT (TREE_TYPE (b->decl)) != TYPE_MAIN_VARIANT (type))) { + auto_diagnostic_group d; if (warning_at (loc, OPT_Wc___compat, ("using %qD as both a typedef and a tag is " "invalid in C++"), b->decl) @@ -1823,8 +1824,6 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, tree *newtypep, tree *oldtypep) { tree newtype, oldtype; - bool pedwarned = false; - bool warned = false; bool retval = true; #define DECL_EXTERN_INLINE(DECL) (DECL_DECLARED_INLINE_P (DECL) \ @@ -1847,6 +1846,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, && DECL_BUILT_IN (olddecl) && !C_DECL_DECLARED_BUILTIN (olddecl))) { + auto_diagnostic_group d; error ("%q+D redeclared as different kind of symbol", newdecl); locate_old_decl (olddecl); } @@ -1864,11 +1864,16 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, given scope. */ if (TREE_CODE (olddecl) == CONST_DECL) { + auto_diagnostic_group d; error ("redeclaration of enumerator %q+D", newdecl); locate_old_decl (olddecl); return false; } + bool pedwarned = false; + bool warned = false; + auto_diagnostic_group d; + if (!comptypes (oldtype, newtype)) { if (TREE_CODE (olddecl) == FUNCTION_DECL @@ -2052,6 +2057,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, ) && same_translation_unit_p (newdecl, olddecl)) { + auto_diagnostic_group d; error ("redefinition of %q+D", newdecl); locate_old_decl (olddecl); return false; @@ -2062,11 +2068,14 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, the argument types must be checked specially. */ else if (DECL_INITIAL (olddecl) && !prototype_p (oldtype) && prototype_p (newtype) - && TYPE_ACTUAL_ARG_TYPES (oldtype) - && !validate_proto_after_old_defn (newdecl, newtype, oldtype)) + && TYPE_ACTUAL_ARG_TYPES (oldtype)) { - locate_old_decl (olddecl); - return false; + auto_diagnostic_group d; + if (!validate_proto_after_old_defn (newdecl, newtype, oldtype)) + { + locate_old_decl (olddecl); + return false; + } } /* A non-static declaration (even an "extern") followed by a static declaration is undefined behavior per C99 6.2.2p3-5,7. @@ -2087,6 +2096,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, if (!DECL_IS_BUILTIN (olddecl) && !DECL_EXTERN_INLINE (olddecl)) { + auto_diagnostic_group d; error ("static declaration of %q+D follows " "non-static declaration", newdecl); locate_old_decl (olddecl); @@ -2097,6 +2107,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, { if (DECL_CONTEXT (olddecl)) { + auto_diagnostic_group d; error ("non-static declaration of %q+D follows " "static declaration", newdecl); locate_old_decl (olddecl); @@ -2121,6 +2132,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, DECL_ATTRIBUTES (olddecl)) != NULL; if (newa != olda) { + auto_diagnostic_group d; error_at (input_location, "%<gnu_inline%> attribute present on %q+D", newa ? newdecl : olddecl); error_at (DECL_SOURCE_LOCATION (newa ? olddecl : newdecl), @@ -2141,6 +2153,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, } else if (DECL_THREAD_LOCAL_P (newdecl) != DECL_THREAD_LOCAL_P (olddecl)) { + auto_diagnostic_group d; if (DECL_THREAD_LOCAL_P (newdecl)) error ("thread-local declaration of %q+D follows " "non-thread-local declaration", newdecl); @@ -2155,6 +2168,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, /* Multiple initialized definitions are not allowed (6.9p3,5). */ if (DECL_INITIAL (newdecl) && DECL_INITIAL (olddecl)) { + auto_diagnostic_group d; error ("redefinition of %q+D", newdecl); locate_old_decl (olddecl); return false; @@ -2175,6 +2189,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, { if (!DECL_FILE_SCOPE_P (olddecl)) { + auto_diagnostic_group d; error ("extern declaration of %q+D follows " "declaration with no linkage", newdecl); locate_old_decl (olddecl); @@ -2189,6 +2204,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, } else { + auto_diagnostic_group d; if (TREE_PUBLIC (newdecl)) error ("non-static declaration of %q+D follows " "static declaration", newdecl); @@ -2211,12 +2227,14 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, } else if (DECL_EXTERNAL (olddecl)) { + auto_diagnostic_group d; error ("declaration of %q+D with no linkage follows " "extern declaration", newdecl); locate_old_decl (olddecl); } else { + auto_diagnostic_group d; error ("redeclaration of %q+D with no linkage", newdecl); locate_old_decl (olddecl); } @@ -2263,6 +2281,7 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl, if (TREE_CODE (newdecl) == PARM_DECL && (!TREE_ASM_WRITTEN (olddecl) || TREE_ASM_WRITTEN (newdecl))) { + auto_diagnostic_group d; error ("redefinition of parameter %q+D", newdecl); locate_old_decl (olddecl); return false; @@ -2778,7 +2797,6 @@ warn_if_shadowing (tree new_decl) DECL_SOURCE_LOCATION (b->decl)))) { tree old_decl = b->decl; - bool warned = false; if (old_decl == error_mark_node) { @@ -2786,7 +2804,10 @@ warn_if_shadowing (tree new_decl) "non-variable", new_decl); break; } - else if (TREE_CODE (old_decl) == PARM_DECL) + + bool warned = false; + auto_diagnostic_group d; + if (TREE_CODE (old_decl) == PARM_DECL) { enum opt_code warning_code; @@ -3123,6 +3144,7 @@ implicit_decl_warning (location_t loc, tree id, tree olddecl) return; bool warned; + auto_diagnostic_group d; name_hint hint; if (!olddecl) hint = lookup_name_fuzzy (id, FUZZY_LOOKUP_FUNCTION_NAME, loc); @@ -3435,6 +3457,7 @@ implicitly_declare (location_t loc, tree functionid) { if (!comptypes (newtype, TREE_TYPE (decl))) { + auto_diagnostic_group d; error_at (loc, "incompatible implicit declaration of " "function %qD", decl); locate_old_decl (decl); @@ -3487,6 +3510,7 @@ undeclared_variable (location_t loc, tree id) static bool already = false; struct c_scope *scope; + auto_diagnostic_group d; if (current_function_decl == NULL_TREE) { name_hint guessed_id = lookup_name_fuzzy (id, FUZZY_LOOKUP_NAME, loc); @@ -3686,6 +3710,7 @@ declare_label (tree name) at this scope */ if (b && B_IN_CURRENT_SCOPE (b)) { + auto_diagnostic_group d; error ("duplicate label declaration %qE", name); locate_old_decl (b->decl); @@ -3784,6 +3809,7 @@ define_label (location_t location, tree name) || (DECL_CONTEXT (label) != current_function_decl && C_DECLARED_LABEL_FLAG (label)))) { + auto_diagnostic_group d; error_at (location, "duplicate label %qD", label); locate_old_decl (label); return NULL_TREE; @@ -6720,6 +6746,7 @@ grokdeclarator (const struct c_declarator *declarator, || (current_scope == file_scope && B_IN_EXTERNAL_SCOPE (b))) && TYPE_MAIN_VARIANT (b->decl) != TYPE_MAIN_VARIANT (type)) { + auto_diagnostic_group d; if (warning_at (declarator->id_loc, OPT_Wc___compat, ("using %qD as both a typedef and a tag is " "invalid in C++"), decl) @@ -8794,6 +8821,7 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator, { if (stdarg_p (TREE_TYPE (old_decl))) { + auto_diagnostic_group d; warning_at (loc, 0, "%q+D defined as variadic function " "without prototype", decl1); locate_old_decl (old_decl); |