| Issue |
71046
|
| Summary |
clang 17.0.2: No "unreachable code" warning if source file included in another source file
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
pkl97
|
When compiling unreachable_warning.cpp (with the content below) using option -Wunreachable-code-break, a warning is triggered as expected:
```c++
void f(int i)
{
switch (i)
{
case 3: return; break;
}
}
```
The warning emitted:
```console
[user@host]$ clang++ -c -Wunreachable-code-break unreachable_warning.cpp
unreachable_warning.cpp:5:25: warning: 'break' will never be executed [-Wunreachable-code-break]
case 3: return; break;
^~~~~
1 warning generated.
```
However if unreachable_warning.cpp is wrapped in another source file (as is frequently done in "unity builds" or "jumbo builds") then the warning is no longer emitted:
```
[user@host]$ cat unity_build.cpp
#include "unreachable_warning.cpp"
[user@host]$ clang++ -c -Wunreachable-code-break unity_build.cpp
[user@host]$
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs