[clang] [Clang] skip warnings for constructors marked with the [[noreturn]] attribute (PR #115558)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 19 04:51:07 PST 2024


================
@@ -49,3 +49,15 @@ void check() {
   test_type(g);
   test_type(h); // expected-note {{instantiation}}
 }
+
+namespace GH63009 {
+struct S {
+  [[noreturn]] S() { throw int {}; }
+};
+
+int test_no_return_constructor() { S(); } // ok
----------------
AaronBallman wrote:

Can you also add a test case (in a different test file under SemaCXX) for:
```
struct S {
  [[noreturn]] S();
};

int foo();
int func() {
  S s;
  foo(); // Unreachable warning
} // No "does not return a value" warning
```

https://github.com/llvm/llvm-project/pull/115558


More information about the cfe-commits mailing list