[clang] ce07de2 - [clang][tests] Add test for C++ DR2406

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 10 05:53:10 PST 2022


Author: Timm Bäder
Date: 2022-02-10T14:52:30+01:00
New Revision: ce07de234b77dc6cc263cdf4081eace5761d6b5a

URL: https://github.com/llvm/llvm-project/commit/ce07de234b77dc6cc263cdf4081eace5761d6b5a
DIFF: https://github.com/llvm/llvm-project/commit/ce07de234b77dc6cc263cdf4081eace5761d6b5a.diff

LOG: [clang][tests] Add test for C++ DR2406

Clang already handles this fine, so add a test case to let the
make_cxx_dr_status script pick it up.

Differential Revision: https://reviews.llvm.org/D119224

Added: 
    clang/test/CXX/drs/dr2406.cpp

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/clang/test/CXX/drs/dr2406.cpp b/clang/test/CXX/drs/dr2406.cpp
new file mode 100644
index 0000000000000..7ea0870fb70b3
--- /dev/null
+++ b/clang/test/CXX/drs/dr2406.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -x c++ %s  -verify
+
+// dr2406: yes
+
+void fallthrough(int n) {
+  void g(), h(), i();
+  switch (n) {
+  case 1:
+  case 2:
+    g();
+    [[fallthrough]];
+  case 3: // warning on fallthrough discouraged
+    do {
+      [[fallthrough]]; // expected-error {{fallthrough annotation does not directly precede switch label}}
+    } while (false);
+  case 6:
+    do {
+      [[fallthrough]]; // expected-error {{fallthrough annotation does not directly precede switch label}}
+    } while (n);
+  case 7:
+    while (false) {
+      [[fallthrough]]; // expected-error {{fallthrough annotation does not directly precede switch label}}
+    }
+  case 5:
+    h();
+  case 4: // implementation may warn on fallthrough
+    i();
+    [[fallthrough]]; // expected-error {{fallthrough annotation does not directly precede switch label}}
+  }
+}


        


More information about the cfe-commits mailing list