Commit f208b768 by Jason Merrill Committed by Jason Merrill

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
parent 3a2f6fac
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.
......
......@@ -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);
......
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.
......
// 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>;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment