re PR c++/39560 (Erroneous warnings 'unused variable' in a templated class method with union)

PR c++/39560
	* decl2.c (build_anon_union_vars): Set DECL_ARTIFICIAL.

From-SVN: r154133
This commit is contained in:
Jason Merrill 2009-11-12 18:21:33 -05:00 committed by Jason Merrill
parent 3a2f6fac4d
commit f208b76886
4 changed files with 33 additions and 0 deletions

View 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.

View 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);

View 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.

View File

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