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
This commit is contained in:
Marek Polacek 2015-06-08 10:35:24 +00:00 committed by Marek Polacek
parent 02de9c16f0
commit d216b2e085
4 changed files with 28 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2015-06-08 Marek Polacek <polacek@redhat.com>
PR sanitizer/66452
* toplev.c (check_global_declaration): Don't warn about artificial
decls.
2015-06-08 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/66436

View File

@ -1,3 +1,8 @@
2015-06-08 Marek Polacek <polacek@redhat.com>
PR sanitizer/66452
* g++.dg/ubsan/pr66452.C: New test.
2015-06-08 Tom de Vries <tom@codesourcery.com>
PR tree-optimization/66436

View File

@ -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;
}

View File

@ -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)