Issue 61471
Summary [misc-definitions-in-headers] incorrectly warns definition in unnamed namespace
Labels new issue
Assignees
Reporter namniav
    This was first reported in clangd/clangd#1543 and I was told that it should be reported here.

Clang incorrectly warns definition in unnamed namespace in header file.
```c++
// test.hpp
namespace a {
  namespace  /*b*/  {
    static int c[[maybe_unused]] = 42; // even static doesn't help
 }
}
```
```c++
test.hpp|3 col 16 warning| Variable 'c' defined in a header file; variable definitions in header files can lead to ODR violations [misc-definitions-in-headers]
```
However, this only happens in unnamed namespace. If I uncomment `b`, the warning is gone.

**System information**

Output of `clang --version`:
```
Homebrew clang version 15.0.7
Target: arm64-apple-darwin21.4.0
Thread model: posix
```
Editor/LSP plugin: VIM 9.0 + YouCompleteMe
Operating system: MacOS

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to