diff options
author | Marek Polacek <polacek@redhat.com> | 2016-09-26 09:42:50 +0000 |
---|---|---|
committer | Marek Polacek <mpolacek@gcc.gnu.org> | 2016-09-26 09:42:50 +0000 |
commit | 81fea426da8c4687bb32e6894dc26f00ae211822 (patch) | |
tree | 8b84b3de175727d09b7dcf1b5703e0d46b64f9e7 /gcc/testsuite/c-c++-common/attr-fallthrough-2.c | |
parent | 392fa55c799358e198ca85fbea548e60359133c5 (diff) | |
download | gcc-81fea426da8c4687bb32e6894dc26f00ae211822.zip gcc-81fea426da8c4687bb32e6894dc26f00ae211822.tar.gz gcc-81fea426da8c4687bb32e6894dc26f00ae211822.tar.bz2 |
Implement -Wimplicit-fallthrough.
Co-Authored-By: Jakub Jelinek <jakub@redhat.com>
From-SVN: r240485
Diffstat (limited to 'gcc/testsuite/c-c++-common/attr-fallthrough-2.c')
-rw-r--r-- | gcc/testsuite/c-c++-common/attr-fallthrough-2.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/gcc/testsuite/c-c++-common/attr-fallthrough-2.c b/gcc/testsuite/c-c++-common/attr-fallthrough-2.c new file mode 100644 index 0000000..959564b --- /dev/null +++ b/gcc/testsuite/c-c++-common/attr-fallthrough-2.c @@ -0,0 +1,54 @@ +/* PR c/7652 */ +/* { dg-do compile } */ +/* { dg-options "-Wall -Wextra -Wpedantic -Wno-unused -Wno-implicit-fallthrough" } */ + +extern void bar (int); +void +fn (int i) +{ + switch (i) + { + case 1: + bar (1); + __attribute__((used)); + /* { dg-warning "empty declaration" "" { target c } 13 } */ + /* { dg-warning "ignored" "" { target c++ } 13 } */ + case 2: + bar (1); + __attribute__((foo)); + /* { dg-warning "empty declaration" "" { target c } 18 } */ + /* { dg-warning "ignored" "" { target c++ } 18 } */ + case 3: + bar (1); + __attribute__((fallthrough)) /* { dg-warning "not followed" "" { target c } } */ + case 4: /* { dg-error "expected" } */ + bar (1); + __attribute__((fallthrough)) 1; + /* { dg-error "expected" "" { target c } 26 } */ + /* { dg-warning "not followed" "" { target *-*-* } 26 } */ + case 5: + bar (1); + __attribute__((fallthrough)) int i; /* { dg-warning "ignored|not followed" } */ + case 6: + bar (1); + __attribute__((fallthrough ("x"))); /* { dg-warning "specified with a parameter" } */ + case 7: + bar (1); + __attribute__((fallthrough, fallthrough)); /* { dg-warning "attribute specified multiple times" } */ + case 8: + bar (1); + __attribute__((fallthrough)); + case 9: + __attribute__((fallthrough)); + /* { dg-warning "not preceding" "" { target *-*-* } 42 } */ + bar (1); + case 10: + bar (1); + __attribute__((unused, fallthrough)); /* { dg-warning "attribute ignored" } */ + case 11: + bar (1); + __attribute__((fallthrough, unused)); /* { dg-warning "attribute ignored" } */ + default: + bar (99); + } +} |