ping
On Fri, Sep 1 2023 at 03:02:41 PM -04:00:00, Hamza Mahfooz
<some...@effective-light.com> wrote:
Resolves:
PR c/110947 - Should -Wmissing-variable-declarations not trigger on
register variables?
gcc/c/ChangeLog:
PR c/110947
* c-decl.cc (start_decl): don't emit
-Wmissing-variable-declarations for DECL_REGISTER VAR_DECLs.
gcc/testsuite/ChangeLog:
PR c/110947
* gcc.dg/pr110947.c: New test.
Signed-off-by: Hamza Mahfooz <some...@effective-light.com>
---
Please push this for me if you think it looks good. Since, I don't
have
write access to the repository.
v2: put "target" before the relevant architectures in pr110947.c.
---
gcc/c/c-decl.cc | 3 ++-
gcc/testsuite/gcc.dg/pr110947.c | 4 ++++
2 files changed, 6 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/gcc.dg/pr110947.c
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index 1f9eb44dbaa..819af6aa050 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -5376,7 +5376,8 @@ start_decl (struct c_declarator *declarator,
struct c_declspecs *declspecs,
warning (OPT_Wmain, "%q+D is usually a function", decl);
if (warn_missing_variable_declarations && VAR_P (decl)
- && !DECL_EXTERNAL (decl) && TREE_PUBLIC (decl) && old_decl ==
NULL_TREE)
+ && !DECL_EXTERNAL (decl) && !DECL_REGISTER (decl) &&
TREE_PUBLIC (decl)
+ && old_decl == NULL_TREE)
warning_at (DECL_SOURCE_LOCATION (decl),
OPT_Wmissing_variable_declarations,
"no previous declaration for %qD", decl);
diff --git a/gcc/testsuite/gcc.dg/pr110947.c
b/gcc/testsuite/gcc.dg/pr110947.c
new file mode 100644
index 00000000000..3c0b8a82ab3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr110947.c
@@ -0,0 +1,4 @@
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-Wmissing-variable-declarations" } */
+
+register unsigned long current_stack_pointer asm("rsp");
--
2.41.0