(TREE_TYPE (decl)));
if (!comptypes (newtype, TREE_TYPE (decl)))
{
+ auto_diagnostic_group d;
bool warned = warning_at (loc,
OPT_Wbuiltin_declaration_mismatch,
"incompatible implicit "
static void
warn_about_goto (location_t goto_loc, tree label, tree decl)
{
+ auto_diagnostic_group d;
if (variably_modified_type_p (TREE_TYPE (decl), NULL_TREE))
error_at (goto_loc,
"jump into scope of identifier with variably modified type");
else
- warning_at (goto_loc, OPT_Wjump_misses_init,
- "jump skips variable initialization");
+ if (!warning_at (goto_loc, OPT_Wjump_misses_init,
+ "jump skips variable initialization"))
+ return;
inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label);
inform (DECL_SOURCE_LOCATION (decl), "%qD declared here", decl);
}
if (label_vars->label_bindings.left_stmt_expr)
{
+ auto_diagnostic_group d;
error_at (loc, "jump into statement expression");
inform (DECL_SOURCE_LOCATION (label), "label %qD defined here", label);
}
if (g->goto_bindings.stmt_exprs > 0)
{
+ auto_diagnostic_group d;
error_at (g->loc, "jump into statement expression");
inform (DECL_SOURCE_LOCATION (label), "label %qD defined here",
label);
{
if (decl_jump_unsafe (b->decl))
{
+ auto_diagnostic_group d;
+ bool emitted;
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"));
+ emitted = true;
}
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);
+ emitted
+ = warning_at (case_loc, OPT_Wjump_misses_init,
+ "switch jumps over variable initialization");
+ if (emitted)
+ {
+ inform (switch_loc, "switch starts here");
+ inform (DECL_SOURCE_LOCATION (b->decl), "%qD declared here",
+ b->decl);
+ }
}
}
}
if (switch_bindings->stmt_exprs > 0)
{
saw_error = true;
+ auto_diagnostic_group d;
error_at (case_loc, "switch jumps into statement expression");
inform (switch_loc, "switch starts here");
}
if (TYPE_QUALS (field_type) & TYPE_QUAL_CONST)
{
- warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
- "uninitialized const member in %qT is invalid in C++",
- strip_array_types (TREE_TYPE (decl)));
- inform (DECL_SOURCE_LOCATION (field), "%qD should be initialized", field);
+ auto_diagnostic_group d;
+ if (warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wc___compat,
+ "uninitialized const member in %qT is invalid in C++",
+ strip_array_types (TREE_TYPE (decl))))
+ inform (DECL_SOURCE_LOCATION (field), "%qD should be initialized", field);
}
if (RECORD_OR_UNION_TYPE_P (field_type))
/* Complain about arrays of incomplete types. */
if (!COMPLETE_TYPE_P (type))
{
+ auto_diagnostic_group d;
error_at (loc, "array type has incomplete element type %qT",
type);
/* See if we can be more helpful. */
&& loc != UNKNOWN_LOCATION
&& warn_cxx_compat)
{
+ auto_diagnostic_group d;
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");
+ if (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");
+ if (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");
+ if (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();
if (TYPE_SIZE (ref))
{
+ auto_diagnostic_group d;
if (code == UNION_TYPE)
error_at (loc, "redefinition of %<union %E%>", name);
else
if (TYPE_VALUES (enumtype) != NULL_TREE)
{
/* This enum is a named one that has been declared already. */
+ auto_diagnostic_group d;
error_at (loc, "redeclaration of %<enum %E%>", name);
if (enumloc != UNKNOWN_LOCATION)
inform (enumloc, "originally defined here");
/* 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. */
+ auto_diagnostic_group d;
error_at (loc, "%<for%> loop initial declarations "
"are only allowed in C99 or C11 mode");
if (hint)