aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/c-c++-common/Wdangling-else-4.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/c-c++-common/Wdangling-else-4.c')
-rw-r--r--gcc/testsuite/c-c++-common/Wdangling-else-4.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/Wdangling-else-4.c b/gcc/testsuite/c-c++-common/Wdangling-else-4.c
new file mode 100644
index 00000000000..12cc1405a40
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wdangling-else-4.c
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* { dg-options "-Wdangling-else" } */
+
+void bar (int);
+
+void
+foo (int a, int b, int c)
+{
+ if (a) /* { dg-warning "suggest explicit braces to avoid ambiguous .else." } */
+ switch (b)
+ case 0:
+ if (c)
+ bar (1);
+ else
+ bar (2);
+}
+
+void
+baz (int a, int b, int c)
+{
+ if (a)
+ switch (b)
+ {
+ case 0:
+ if (c)
+ bar (1);
+ }
+ else
+ bar (2);
+}
+