From: Matthew Beliveau Date: Fri, 21 Jun 2019 19:58:32 +0000 (+0000) Subject: PR c++/90875 - added -Wswitch-outside-range option X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c27d68ee6d1a15cc12ef20458342202c6c9d4203;p=gcc.git PR c++/90875 - added -Wswitch-outside-range option From-SVN: r272567 --- 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 index 00000000000..29e56f3ba2d --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wswitch-outside-range-1.c @@ -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 index 00000000000..20cc019b209 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wswitch-outside-range-2.c @@ -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 index 00000000000..baf15561af0 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wswitch-outside-range-3.c @@ -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 index 00000000000..d9bd756dc50 --- /dev/null +++ b/gcc/testsuite/c-c++-common/Wswitch-outside-range-4.c @@ -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" } +}