[clang] [clang] [Sema] Suggest [[noreturn]] for void functions that always throw (PR #146234)
Martin Hořeňovský via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 13 14:47:13 PDT 2025
horenmar wrote:
It is not just templates. I just got warning on this code
```cpp
namespace {
[[noreturn]]
void this_throws() {
throw std::runtime_error("Some msg");
}
void this_doesnt_throw() {}
}
```
```
[92/468] Building CXX object tests/ExtraTests/CMakeFiles/PrefixedMacros.dir/X01-PrefixedMacros.cpp.o
/mnt/c/ubuntu/Catch2/tests/ExtraTests/X01-PrefixedMacros.cpp:26:10: warning: function 'this_throws' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
26 | void this_throws() {
| ^
1 warning generated.
```
----
**Clang version:**
```
$ clang++ --version
Ubuntu clang version 21.0.0 (++20250708042308+dcf485609c5c-1~exp1~20250708162410.2527)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-21/bin
```
https://github.com/llvm/llvm-project/pull/146234
More information about the cfe-commits
mailing list