<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/61471>61471</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [misc-definitions-in-headers] incorrectly warns definition in unnamed namespace
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          namniav
      </td>
    </tr>
</table>

<pre>
    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

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVF1vrDYQ_TXmZQQC8xUeeNiPrhqpUaomulKfKmMP4MrYyDa73X9fGXaTbXsb6UoIkDnneM4ZM8w5OWjElpR7Uh4jtvjR2FazSUt2jjojru37KB1cmINeWufB4mysRwFSA1dMD4LQ0_0lz8oiB6YFPK8Ub5QAPzIP0oMbzaIEdPipMaLFhKRHku62-yEIgdTcWIvcqytcmNUOBPZSSy-NDvsuWrMJBYS7mxnHsDgiE2ihl-pDskq3ixO6D9e2Sk-EnsCj88k4z9vipxIDUt-Q8LABrLRdR2gQgEcQgPPMSw5Se-BrkvuJXTv8Y9GLQ0HKIymPQPIjFJTke7hVgGfUd6ow6DShtYcR1a0mIPXxVvLHy93RVwY_nNWHHLhRkFVrilIPpD7AN2Yl6xQCoTUntN6y3RrKHlMMpZ7v4M8GuH-F7YAzDQqZAG_g9fgbnKVRbIOGKKTj8QM9ljre6C4k8z1fP5sLntESegAfTp_R6gojm2fcdv9P_xN47uEZFs3NNKH2QKq0C3KrAt7tg3QwGP3PI7d2dPd2dR4nkLo3dlqL39Yfka-LnxcPpg_y65GHOD6jdQFdpSTf_Y-bCTuLl-13gRsBsjJJk3qDvDM7oCf5DpidqiJm86wwFsxepKZZUiQ3qffRhpwnI1AF9Gyc_Ou7m_4kpDeW0NMvb7_CrJZB6kD49vwCTZICoXv43SwHM80KPb7gzeGMlvmQlFvzCJQXxl_fts-RaHPR5A2LsM2quknLsknraGyzp65hfVXQvuENrZo6fcoxSylrBGVpmUWypSnN0zyrM0rLtE7YE6dPfcazsucdLTpSpDgxqRKlzlNi7BBJ5xZsq6yos0ixDpVbpxSlGi-wfiSUhqFl28CJu2VwpEiVdN59qnjp1Trevj6GPz5yosWqdvR-dqHv6x89SD8uXcLNROgpVHB7xLM1fyL3hJ7Wuh2hp9XX3wEAAP___pq0jg">