summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/switch-5.c
diff options
context:
space:
mode:
authorupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
committerupstream source tree <ports@midipix.org>2015-03-15 20:14:05 -0400
commit554fd8c5195424bdbcabf5de30fdc183aba391bd (patch)
tree976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gcc.dg/switch-5.c
downloadcbb-gcc-4.6.4-upstream.tar.bz2
cbb-gcc-4.6.4-upstream.tar.xz
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository.
Diffstat (limited to 'gcc/testsuite/gcc.dg/switch-5.c')
-rw-r--r--gcc/testsuite/gcc.dg/switch-5.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/switch-5.c b/gcc/testsuite/gcc.dg/switch-5.c
new file mode 100644
index 000000000..5a5849069
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/switch-5.c
@@ -0,0 +1,75 @@
+/* Test diagnostics for switch statements and labels therein. Test
+ with no special options. */
+/* Origin: Joseph Myers <joseph@codesourcery.com> */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void
+f (int a, double d, void *p)
+{
+ switch (d) /* { dg-error "switch quantity not an integer" } */
+ {
+ }
+ switch (p) /* { dg-error "switch quantity not an integer" } */
+ {
+ }
+ switch (a)
+ {
+ case (void *)0: ; /* { dg-error "pointers are not permitted as case values" } */
+ }
+ switch (a)
+ {
+ case (double)0: ; /* { dg-error "case label does not reduce to an integer constant" } */
+ }
+ switch (a)
+ {
+ case (char)0: ;
+ }
+ switch (a)
+ {
+ case 0 ... 0: ;
+ }
+ switch (a)
+ {
+ case 0 ... -1: ; /* { dg-warning "empty range specified" } */
+ }
+ switch (a)
+ {
+ case 0 ... -2: ; /* { dg-warning "empty range specified" } */
+ }
+ switch (a)
+ {
+ case 0:
+ default: /* { dg-error "this is the first default label" } */
+ case 1:
+ default: ; /* { dg-error "multiple default labels in one switch" } */
+ }
+ switch (a)
+ {
+ case 0: /* { dg-error "previously used here" } */
+ case 1:
+ case 0: ; /* { dg-error "duplicate case value" } */
+ }
+ case 1: ; /* { dg-error "case label not within a switch statement" } */
+ default: ; /* { dg-error "'default' label not within a switch statement" } */
+ break; /* { dg-error "break statement not within loop or switch" } */
+ continue; /* { dg-error "continue statement not within a loop" } */
+ switch (a)
+ {
+ case a: ; /* { dg-error "case label does not reduce to an integer constant" } */
+ }
+ switch (a)
+ {
+ case 0: /* { dg-error "this is the first entry overlapping that value" } */
+ case -1 ... 1: /* { dg-error "duplicate \\(or overlapping\\) case value" } */
+ case 2 ... 3: /* { dg-error "previously used here" } */
+ case 2: /* { dg-error "duplicate case value" } */
+ case 4 ... 7: /* { dg-error "this is the first entry overlapping that value" } */
+ case 6 ... 9: ; /* { dg-error "duplicate \\(or overlapping\\) case value" } */
+ }
+ switch (a)
+ {
+ case 0:
+ continue; /* { dg-error "continue statement not within a loop" } */
+ }
+}