re PR sanitizer/66452 ([UBSAN] *.Lubsan_data0' defined but not used)
authorMarek Polacek <polacek@redhat.com>
Mon, 8 Jun 2015 10:35:24 +0000 (10:35 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Mon, 8 Jun 2015 10:35:24 +0000 (10:35 +0000)
PR sanitizer/66452
* toplev.c (check_global_declaration): Don't warn about artificial
decls.

* g++.dg/ubsan/pr66452.C: New test.

From-SVN: r224216

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ubsan/pr66452.C [new file with mode: 0644]
gcc/toplev.c

index a6d3a1ee24ddf25c30337aa2a05ca74c0db41802..c163fcb51e577b2f6b4ecdc10e1c4fee5322c159 100644 (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
index 3231e7db46352b921fb2888dbbabdec5c1a0c4e5..c7902233b318a54dbeba0c768dcc98820e82bb75 100644 (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
diff --git a/gcc/testsuite/g++.dg/ubsan/pr66452.C b/gcc/testsuite/g++.dg/ubsan/pr66452.C
new file mode 100644 (file)
index 0000000..473543c
--- /dev/null
@@ -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;
+}
index fd2ac4e7f2ef12814d7f007fc0f160fab06a2b48..eb8b8ac17594140213779b5bafeb16b83d54e53d 100644 (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)