* [PATCH] Disable -Wunused warning for artificial decls (PR sanitizer/66452)
@ 2015-06-08 10:22 Marek Polacek
2015-06-08 10:23 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Marek Polacek @ 2015-06-08 10:22 UTC (permalink / raw)
To: GCC Patches; +Cc: Jakub Jelinek, Richard Biener
This PR is about a bogus -Wunused-variable warning about an internal
structure (*.Lubsan_data*), exposed by the debug-early merge.
I think the "defined but not used" warning should not be allowed for
the compiler-generated entities.
Bootstrapped/regtested on x86_64-linux, ok for trunk?
2015-06-08 Marek Polacek <polacek@redhat.com>
PR sanitizer/66452
* toplev.c (check_global_declaration): Don't warn about artificial
decls.
* g++.dg/ubsan/pr66452.C: New test.
diff --git gcc/testsuite/g++.dg/ubsan/pr66452.C gcc/testsuite/g++.dg/ubsan/pr66452.C
index e69de29..473543c 100644
--- gcc/testsuite/g++.dg/ubsan/pr66452.C
+++ gcc/testsuite/g++.dg/ubsan/pr66452.C
@@ -0,0 +1,16 @@
+// PR sanitizer/66452
+// { dg-do compile }
+// { dg-options "-Wall -fsanitize=undefined" }
+
+class A {
+public:
+ A(int);
+};
+class B {
+ A m_fn1() const;
+};
+A B::m_fn1() const {
+ for (int i = 0;i;)
+ ;
+ return 0;
+}
diff --git gcc/toplev.c gcc/toplev.c
index fd2ac4e..eb8b8ac 100644
--- gcc/toplev.c
+++ gcc/toplev.c
@@ -534,6 +534,7 @@ check_global_declaration (tree decl)
to handle multiple external decls in different scopes. */
&& ! (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl)))
&& ! DECL_EXTERNAL (decl)
+ && ! DECL_ARTIFICIAL (decl)
&& ! TREE_PUBLIC (decl)
/* A volatile variable might be used in some non-obvious way. */
&& ! TREE_THIS_VOLATILE (decl)
Marek
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Disable -Wunused warning for artificial decls (PR sanitizer/66452)
2015-06-08 10:22 [PATCH] Disable -Wunused warning for artificial decls (PR sanitizer/66452) Marek Polacek
@ 2015-06-08 10:23 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2015-06-08 10:23 UTC (permalink / raw)
To: Marek Polacek; +Cc: GCC Patches, Jakub Jelinek
On Mon, 8 Jun 2015, Marek Polacek wrote:
> This PR is about a bogus -Wunused-variable warning about an internal
> structure (*.Lubsan_data*), exposed by the debug-early merge.
>
> I think the "defined but not used" warning should not be allowed for
> the compiler-generated entities.
>
> Bootstrapped/regtested on x86_64-linux, ok for trunk?
Ok.
Thanks,
Richard.
> 2015-06-08 Marek Polacek <polacek@redhat.com>
>
> PR sanitizer/66452
> * toplev.c (check_global_declaration): Don't warn about artificial
> decls.
>
> * g++.dg/ubsan/pr66452.C: New test.
>
> diff --git gcc/testsuite/g++.dg/ubsan/pr66452.C gcc/testsuite/g++.dg/ubsan/pr66452.C
> index e69de29..473543c 100644
> --- gcc/testsuite/g++.dg/ubsan/pr66452.C
> +++ gcc/testsuite/g++.dg/ubsan/pr66452.C
> @@ -0,0 +1,16 @@
> +// PR sanitizer/66452
> +// { dg-do compile }
> +// { dg-options "-Wall -fsanitize=undefined" }
> +
> +class A {
> +public:
> + A(int);
> +};
> +class B {
> + A m_fn1() const;
> +};
> +A B::m_fn1() const {
> + for (int i = 0;i;)
> + ;
> + return 0;
> +}
> diff --git gcc/toplev.c gcc/toplev.c
> index fd2ac4e..eb8b8ac 100644
> --- gcc/toplev.c
> +++ gcc/toplev.c
> @@ -534,6 +534,7 @@ check_global_declaration (tree decl)
> to handle multiple external decls in different scopes. */
> && ! (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl)))
> && ! DECL_EXTERNAL (decl)
> + && ! DECL_ARTIFICIAL (decl)
> && ! TREE_PUBLIC (decl)
> /* A volatile variable might be used in some non-obvious way. */
> && ! TREE_THIS_VOLATILE (decl)
>
> Marek
>
>
--
Richard Biener <rguenther@suse.de>
SUSE LINUX GmbH, GF: Felix Imendoerffer, Jane Smithard, Dilip Upmanyu, Graham Norton, HRB 21284 (AG Nuernberg)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-08 10:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-08 10:22 [PATCH] Disable -Wunused warning for artificial decls (PR sanitizer/66452) Marek Polacek
2015-06-08 10:23 ` Richard Biener
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).