From: Marek Polacek Date: Mon, 8 Jun 2015 10:35:24 +0000 (+0000) Subject: re PR sanitizer/66452 ([UBSAN] *.Lubsan_data0' defined but not used) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d216b2e085ddba748c0f61c5487783281e1f5f9f;p=gcc.git re PR sanitizer/66452 ([UBSAN] *.Lubsan_data0' defined but not used) PR sanitizer/66452 * toplev.c (check_global_declaration): Don't warn about artificial decls. * g++.dg/ubsan/pr66452.C: New test. From-SVN: r224216 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a6d3a1ee24d..c163fcb51e5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2015-06-08 Marek Polacek + + PR sanitizer/66452 + * toplev.c (check_global_declaration): Don't warn about artificial + decls. + 2015-06-08 Tom de Vries PR tree-optimization/66436 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3231e7db463..c7902233b31 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-06-08 Marek Polacek + + PR sanitizer/66452 + * g++.dg/ubsan/pr66452.C: New test. + 2015-06-08 Tom de Vries PR tree-optimization/66436 diff --git a/gcc/testsuite/g++.dg/ubsan/pr66452.C b/gcc/testsuite/g++.dg/ubsan/pr66452.C new file mode 100644 index 00000000000..473543ca899 --- /dev/null +++ b/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 a/gcc/toplev.c b/gcc/toplev.c index fd2ac4e7f2e..eb8b8ac1759 100644 --- a/gcc/toplev.c +++ b/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)