+2019-11-21 Joseph Myers <joseph@codesourcery.com>
+
+ * gimplify.c (expand_FALLTHROUGH_r, expand_FALLTHROUGH): Use
+ pedwarn instead of warning_at for fallthrough not preceding a case
+ or default label.
+
2019-11-22 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR tree-optimization/92608
+2019-11-21 Joseph Myers <joseph@codesourcery.com>
+
+ * c-attribs.c (handle_fallthrough_attribute): Use pedwarn instead
+ of warning.
+
2019-11-19 Joseph Myers <joseph@codesourcery.com>
* c-common.c (attribute_fallthrough_p): In C, use pedwarn not
handle_fallthrough_attribute (tree *, tree name, tree, int,
bool *no_add_attrs)
{
- warning (OPT_Wattributes, "%qE attribute ignored", name);
+ pedwarn (input_location, OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
return NULL_TREE;
}
gsi_next (&gsi2);
}
if (!found)
- warning_at (loc, 0, "attribute %<fallthrough%> not preceding "
- "a case label or default label");
+ pedwarn (loc, 0, "attribute %<fallthrough%> not preceding "
+ "a case label or default label");
}
break;
default:
if (wi.callback_result == integer_zero_node)
/* We've found [[fallthrough]]; at the end of a switch, which the C++
standard says is ill-formed; see [dcl.attr.fallthrough]. */
- warning_at (loc, 0, "attribute %<fallthrough%> not preceding "
- "a case label or default label");
+ pedwarn (loc, 0, "attribute %<fallthrough%> not preceding "
+ "a case label or default label");
}
\f
+2019-11-21 Joseph Myers <joseph@codesourcery.com>
+
+ * gcc.dg/c2x-attr-fallthrough-6.c: New test. Split out from
+ c2x-attr-fallthrough-3.c.
+ * gcc.dg/c2x-attr-fallthrough-1.c: Add more tests.
+ * gcc.dg/c2x-attr-fallthrough-2.c: Update expected diagnostics.
+ * gcc.dg/c2x-attr-fallthrough-3.c: Split inside-switch part of
+ test out to c2x-attr-fallthrough-6.c.
+
2019-11-22 Prathamesh Kulkarni <prathamesh.kulkarni@linaro.org>
PR tree-optimization/92608
/* { dg-options "-std=c2x -pedantic-errors -Wextra" } */
int
-f (int a)
+f (int a, int c)
{
int b = 2;
switch (a)
case 5:
b += 1;
break;
+ case 6:
+ if (c == 2)
+ {
+ [[fallthrough]];
+ }
+ else
+ {
+ [[fallthrough]];
+ }
+ case 7:
+ b += 3;
+ [[fallthrough]];
+ default:
+ b += 8;
+ break;
}
return b;
}
int
f (int a)
{
- [[fallthrough]] int b = 2; /* { dg-warning "not followed by|ignored" } */
+ [[fallthrough]] int b = 2; /* { dg-warning "not followed by" } */
+ /* { dg-error "ignored" "ignored" { target *-*-* } .-1 } */
switch (a)
{
case 1:
/* Test C2x attribute syntax. Invalid use of fallthrough attribute
- outside switch or in bad context inside switch. */
+ outside switch. */
/* { dg-do compile } */
/* { dg-options "-std=c2x -pedantic-errors -Wextra" } */
f (int a)
{
[[fallthrough]]; /* { dg-error "invalid use of attribute 'fallthrough'" } */
- switch (a)
- {
- case 1:
- a++;
- [[fallthrough]]; /* { dg-warning "attribute 'fallthrough' not preceding a case label or default label" } */
- a++;
- }
return a;
}
--- /dev/null
+/* Test C2x attribute syntax. Invalid use of fallthrough attribute in
+ bad context inside switch. */
+/* { dg-do compile } */
+/* { dg-options "-std=c2x -pedantic-errors -Wextra" } */
+
+int
+f (int a)
+{
+ switch (a)
+ {
+ case 1:
+ a++;
+ [[fallthrough]]; /* { dg-error "attribute 'fallthrough' not preceding a case label or default label" } */
+ a++;
+ [[fallthrough]]; /* { dg-error "attribute 'fallthrough' not preceding a case label or default label" } */
+ }
+ return a;
+}