]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/39560 (Erroneous warnings 'unused variable' in a templated class method...
authorJason Merrill <jason@redhat.com>
Thu, 12 Nov 2009 23:21:33 +0000 (18:21 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 12 Nov 2009 23:21:33 +0000 (18:21 -0500)
PR c++/39560
* decl2.c (build_anon_union_vars): Set DECL_ARTIFICIAL.

From-SVN: r154133

gcc/cp/ChangeLog
gcc/cp/decl2.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/anon7.C [new file with mode: 0644]

index 333c84d88b5867a4ef3e032da891033402a75023..aa2563a56354e367c3d1088b695dbda6098215da 100644 (file)
@@ -1,5 +1,8 @@
 2009-11-12  Jason Merrill  <jason@redhat.com>
 
+       PR c++/39560
+       * decl2.c (build_anon_union_vars): Set DECL_ARTIFICIAL.
+
        PR c++/37037
        * decl.c (grokdeclarator): Don't generate a void PARM_DECL.
 
index 510aa8faec1c5a1bc2443f18480dee55ea02b518..7c3f7c058d6ad5130957593f9743ae1ef91aabec 100644 (file)
@@ -1313,6 +1313,7 @@ build_anon_union_vars (tree type, tree object)
          decl = build_decl (input_location,
                             VAR_DECL, DECL_NAME (field), TREE_TYPE (field));
          DECL_ANON_UNION_VAR_P (decl) = 1;
+         DECL_ARTIFICIAL (decl) = 1;
 
          base = get_base_address (object);
          TREE_PUBLIC (decl) = TREE_PUBLIC (base);
index 49f2e6ab2d1006f1d6d1d108fb8792443cea0e40..f616d2ed14cf2fd50ac572294240c280d4528b0c 100644 (file)
@@ -1,5 +1,8 @@
 2009-11-12  Jason Merrill  <jason@redhat.com>
 
+       PR c++/39560
+       * g++.dg/lookup/anon7.C: New.
+
        PR c++/37037
        * g++.dg/template/typedef21.C: New.
 
diff --git a/gcc/testsuite/g++.dg/lookup/anon7.C b/gcc/testsuite/g++.dg/lookup/anon7.C
new file mode 100644 (file)
index 0000000..79cad0a
--- /dev/null
@@ -0,0 +1,26 @@
+// PR c++/39560
+// { dg-options -Wunused }
+
+struct X { };
+
+class Z {
+public:
+  X* cc(int c);
+};
+
+class F {
+public:
+  typedef X* (Z::*MethO)(int);
+  typedef X* (F::*MethF)(int);
+  template<MethO m>
+  X* xwrapper(int i) {
+    union {
+      Z *z;
+      F *f;
+    };                         // { dg-bogus "unused" }
+    f = this;
+    return ((z->*m)(i));
+  }
+};
+
+F::MethF meth = &F::xwrapper<&Z::cc>;