<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64509>64509</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Should -Wmissing-variable-declarations not trigger on `register` variables?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:diagnostics
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nickdesaulniers
</td>
</tr>
</table>
<pre>
Via: https://lore.kernel.org/all/CAKwvOd=8kxkD9p+WW-F047ShN=r32SLYYfpgZhyDw3BXTDd-KA@mail.gmail.com/
I'm looking to enable -Wmissing-variable-declarations in the Linux kernel (gcc-14 just gained support for that warning, too).
In one case I noticed that:
```c
register unsigned long current_stack_pointer asm("rsp");
```
declared in a header would trigger this:
```
> arch/x86/include/asm/asm.h:208:10: note: declare 'static' if the variable is not intended to be used outside of this translation unit
```
but note that variables with register storage CANNOT also be static.
So we could add:
```c
extern unsigned long current_stack_pointer;
```
before the
```c
register unsigned long current_stack_pointer asm("rsp");
```
but that seems excessive. Perhaps we can simply not diagnose in that case? (I will file a bug against GCC as well).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VEtv4zYQ_jXUZWCDph62Djo4dlUEu8gWyKLp9rKgyLHEmCYFDhU7_76g7DRNH2hPBQwKNEjO95j5JJHpHWLDyjtW7jM5xcGHxhl11Ehyss5goKzz-rX52UiWb2GIcSSWb5lomWitD7g8YnBolz70TLTSWiba3fbT-eWLZvl-c7wc9_XIxN3T06LlxfpxeGD5PuTi8fO3b4ex_3V43Z_zu1--7vXi05YV_CSNXfbzqvwp1eF7xrfX9Z6J9Qms90fjeoge0MnOIiyeTobIuH7xIoNJfy00KiuDjMY7AuMgDgifjZsucAUMTGx6pRarAp4nitBL41ADTePoQ4SDDxAHGeEsgzOuZ2IH0Xsm6uUHQA68Q1CSEO7B-WgU6vliEukPB1nFrz913QfsDUUMMLnZBA3Wux7UF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