https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110947
Bug ID: 110947
Summary: Should -Wmissing-variable-declarations not trigger on
register variables?
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: ndesaulniers at google dot com
Target Milestone: ---
Via:
https://lore.kernel.org/all/CAKwvOd=8kxkD9p+WW-F047ShN=r32slyyfpgzhydw3bxtdd...@mail.gmail.com/
I'm looking to enable -Wmissing-variable-declarations in the Linux kernel
(gcc-14 just gained support for this warning).
In one case I noticed that:
register unsigned long current_stack_pointer asm("rsp");
declared in a header would trigger this:
> no previous declaration for 'current_stack_pointer'
> [-Wmissing-variable-declarations]
So we could add:
extern unsigned long current_stack_pointer;
before the
register unsigned long current_stack_pointer asm("rsp");
but that seems excessive. Perhaps we can simply not diagnose in that case?
Filed this bug report against clang as well:
https://github.com/llvm/llvm-project/issues/64509