* [PATCH v2] c: don't emit -Wmissing-variable-declarations for register variables [PR110947]
@ 2023-09-01 19:02 Hamza Mahfooz
2023-10-30 21:59 ` Hamza Mahfooz
0 siblings, 1 reply; 2+ messages in thread
From: Hamza Mahfooz @ 2023-09-01 19:02 UTC (permalink / raw)
To: gcc-patches
Cc: Nick Desaulniers, Nathan Chancellor, Richard Biener,
Joseph Myers, Marek Polacek, Martin Uecker, Hamza Mahfooz
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 <someguy@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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] c: don't emit -Wmissing-variable-declarations for register variables [PR110947]
2023-09-01 19:02 [PATCH v2] c: don't emit -Wmissing-variable-declarations for register variables [PR110947] Hamza Mahfooz
@ 2023-10-30 21:59 ` Hamza Mahfooz
0 siblings, 0 replies; 2+ messages in thread
From: Hamza Mahfooz @ 2023-10-30 21:59 UTC (permalink / raw)
To: gcc-patches
Cc: Nick Desaulniers, Nathan Chancellor, Richard Biener,
Joseph Myers, Marek Polacek, Martin Uecker
ping
On Fri, Sep 1 2023 at 03:02:41 PM -04:00:00, Hamza Mahfooz
<someguy@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 <someguy@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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-10-30 22:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-01 19:02 [PATCH v2] c: don't emit -Wmissing-variable-declarations for register variables [PR110947] Hamza Mahfooz
2023-10-30 21:59 ` Hamza Mahfooz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).