summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema
diff options
context:
space:
mode:
authorNathan Huckleberry <nhuck@google.com>2019-08-20 17:16:49 +0000
committerNathan Huckleberry <nhuck@google.com>2019-08-20 17:16:49 +0000
commit1e0affb6e564b7361b0aadb38805f26deff4ecfc (patch)
tree94ae1566bc130995b7c8b50631cdf4f2ff9e4001 /clang/test/Sema
parent86d560ff1b7101506329331fc392a2d67323d298 (diff)
downloadbcm5719-llvm-1e0affb6e564b7361b0aadb38805f26deff4ecfc.tar.gz
bcm5719-llvm-1e0affb6e564b7361b0aadb38805f26deff4ecfc.zip
[Attr] Support _attribute__ ((fallthrough))
Summary: Fixed extraneous matches of non-NullStmt Reviewers: aaron.ballman, rsmith, efriedma, xbolva00 Reviewed By: aaron.ballman, rsmith, xbolva00 Subscribers: riccibruno, arphaman, ziangwan, ojeda, xbolva00, nickdesaulniers, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64838 llvm-svn: 369414
Diffstat (limited to 'clang/test/Sema')
-rw-r--r--clang/test/Sema/fallthrough-attr.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/test/Sema/fallthrough-attr.c b/clang/test/Sema/fallthrough-attr.c
new file mode 100644
index 00000000000..de50ebf39d4
--- /dev/null
+++ b/clang/test/Sema/fallthrough-attr.c
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -std=gnu89 -verify -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -std=gnu99 -verify -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -std=c99 -verify -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -std=c11 -verify -Wimplicit-fallthrough %s
+// RUN: %clang_cc1 -fsyntax-only -std=c2x -DC2X -verify -Wimplicit-fallthrough %s
+
+int fallthrough_attribute_spelling(int n) {
+ switch (n) {
+ case 0:
+ n++;
+ case 1:
+#if defined(C2X)
+// expected-warning@-2{{unannotated fall-through between switch labels}} expected-note@-2{{insert '[[fallthrough]];' to silence this warning}} expected-note@-2{{insert 'break;' to avoid fall-through}}
+#else
+// expected-warning@-4{{unannotated fall-through between switch labels}} expected-note@-4{{insert '__attribute__((fallthrough));' to silence this warning}} expected-note@-4{{insert 'break;' to avoid fall-through}}
+#endif
+ n++;
+ __attribute__((fallthrough));
+ case 2:
+ n++;
+ break;
+ }
+ return n;
+}
OpenPOWER on IntegriCloud