+2017-01-20 Marek Polacek <polacek@redhat.com>
+
+ PR c/79152
+ * gimplify.c (should_warn_for_implicit_fallthrough): Handle consecutive
+ non-case labels.
+
2017-01-20 Alexander Monakov <amonakov@ispras.ru>
* omp-expand.c (expand_omp_simd): Clear PROP_gimple_lomp_dev regardless
if (FALLTHROUGH_LABEL_P (label))
return false;
- /* Don't warn for a non-case label followed by a statement:
+ /* Don't warn for non-case labels followed by a statement:
case 0:
foo ();
label:
as these are likely intentional. */
if (!case_label_p (&gimplify_ctxp->case_labels, label))
{
- gsi_next (&gsi);
+ tree l;
+ while (!gsi_end_p (gsi)
+ && gimple_code (gsi_stmt (gsi)) == GIMPLE_LABEL
+ && (l = gimple_label_label (as_a <glabel *> (gsi_stmt (gsi))))
+ && !case_label_p (&gimplify_ctxp->case_labels, l))
+ gsi_next (&gsi);
if (gsi_end_p (gsi) || gimple_code (gsi_stmt (gsi)) != GIMPLE_LABEL)
return false;
}
+2017-01-20 Marek Polacek <polacek@redhat.com>
+
+ PR c/79152
+ * c-c++-common/Wimplicit-fallthrough-35.c: New test.
+
2017-01-20 Thomas Preud'homme <thomas.preudhomme@arm.com>
* lib/target-supports.exp (check_configured_with): New procedure.
--- /dev/null
+/* PR c/79152 */
+/* { dg-do compile } */
+/* { dg-options "-Wimplicit-fallthrough" } */
+
+extern void foo (int);
+
+void
+f (int i)
+{
+ switch (i)
+ {
+ case 0:
+ foo (0);
+l1:
+ foo (1);
+ }
+
+ switch (i)
+ {
+ case 0:
+ foo (0);
+l2:;
+ }
+
+ switch (i)
+ {
+ case 0:
+ foo (0);
+l3:
+l4:
+ foo (1);
+ }
+
+ switch (i)
+ {
+ case 0:
+ foo (0);
+l5:
+l6:;
+ }
+
+ switch (i)
+ {
+ case 0:
+ foo (0); /* { dg-warning "statement may fall through" } */
+l7:
+l8:
+ case 1:
+ foo (1);
+ }
+
+ switch (i)
+ {
+ case 0:
+ foo (0); /* { dg-warning "statement may fall through" } */
+l9:
+ case 1:
+l10:
+ foo (1);
+ }
+}