Issue 123064
Summary clang's -Wunreachable-code does not fire if the first unreachable line is a macro
Labels clang:frontend
Assignees
Reporter nico
    This warns (as it should):

```
thakis@Mac src % cat notreach.cc 
[[noreturn]] void notreached();
void g();

void f() {
 notreached();
  g();
}

% clang -c notreach.cc -Wunreachable-code
notreach.cc:6:3: warning: code will never be executed [-Wunreachable-code]
    6 |   g();
      |   ^
1 warning generated.
```

This doesn't:

```
% cat notreach2.cc 
[[noreturn]] void notreached();
void g();

#define MY_MACRO(x) (void)(x)

void f() {
  notreached();
  MY_MACRO(5);
  g();
}
% clang -c notreach2.cc -Wunreachable-code
# no output
```

Not emitting unreachable code warnings for the macro itself probably makes sense, but the diagnostic disappearing completely seems surprising.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to