PR c++/90875 - added -Wswitch-outside-range option
authorMatthew Beliveau <mbelivea@gcc.gnu.org>
Fri, 21 Jun 2019 19:58:32 +0000 (19:58 +0000)
committerMatthew Beliveau <mbelivea@gcc.gnu.org>
Fri, 21 Jun 2019 19:58:32 +0000 (19:58 +0000)
From-SVN: r272567

gcc/testsuite/c-c++-common/Wswitch-outside-range-1.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wswitch-outside-range-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wswitch-outside-range-3.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/Wswitch-outside-range-4.c [new file with mode: 0644]

diff --git a/gcc/testsuite/c-c++-common/Wswitch-outside-range-1.c b/gcc/testsuite/c-c++-common/Wswitch-outside-range-1.c
new file mode 100644 (file)
index 0000000..29e56f3
--- /dev/null
@@ -0,0 +1,8 @@
+// PR c++/90875
+
+void f(char c)
+{
+  switch (c)
+    case 300: // { dg-warning "case label value exceeds maximum value for type" }
+    case -300:; // { dg-warning "case label value is less than minimum value for type" }
+}
diff --git a/gcc/testsuite/c-c++-common/Wswitch-outside-range-2.c b/gcc/testsuite/c-c++-common/Wswitch-outside-range-2.c
new file mode 100644 (file)
index 0000000..20cc019
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/90875
+// { dg-options -Wno-switch-outside-range }
+
+void f(char c)
+{
+  switch (c)
+    case 300: //{ dg-bogus "case label value is less than minimum value for type" }
+    case -300:; // { dg-bogus "case label value is less than minimum value for type" }
+}
diff --git a/gcc/testsuite/c-c++-common/Wswitch-outside-range-3.c b/gcc/testsuite/c-c++-common/Wswitch-outside-range-3.c
new file mode 100644 (file)
index 0000000..baf1556
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/90875
+// { dg-options -Wno-pedantic }
+
+void f(char c)
+{
+  switch (c)
+  
+    case -300 ... 300:; // { dg-warning "lower value in case label range less than minimum value for type|upper value in case label range exceeds maximum value for type" }
+}
diff --git a/gcc/testsuite/c-c++-common/Wswitch-outside-range-4.c b/gcc/testsuite/c-c++-common/Wswitch-outside-range-4.c
new file mode 100644 (file)
index 0000000..d9bd756
--- /dev/null
@@ -0,0 +1,9 @@
+// PR c++/90875
+// { dg-options "-Wno-pedantic -Wno-switch-outside-range" }
+
+void f(char c)
+{
+  switch (c)
+  
+    case -300 ... 300:; // { dg-bogus "lower value in case label range less than minimum value for type|upper value in case label range exceeds maximum value for type" }
+}