tbaeder created this revision.
tbaeder added a reviewer: aaron.ballman.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

DR2406 is in "unknown" state according to 
https://clang.llvm.org/cxx_dr_status.html.

The described defects do not exist in clang. The diagnostic messages are 
different but the program is still recognized as ill-formed.

Add a testcase in `clang/test/CXX/drs`. If I understand the 
`make_cxx_dr_status` script correctly, this should update the above webpage.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119224

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


Index: clang/test/CXX/drs/dr2406.cpp
===================================================================
--- /dev/null
+++ 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}}
+  }
+}


Index: clang/test/CXX/drs/dr2406.cpp
===================================================================
--- /dev/null
+++ 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}}
+  }
+}
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to