[PATCH] D119224: [clang][tests] Add a testcase for C++ DR2406

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


This revision was automatically updated to reflect the committed changes.
Closed by commit rGce07de234b77: [clang][tests] Add test for C++ DR2406 (authored by tbaeder).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119224/new/

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}}
+  }
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119224.407504.patch
Type: text/x-patch
Size: 1030 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220210/df3316b6/attachment.bin>


More information about the cfe-commits mailing list