From 8eec242e059982e3c67aa8c9e1141838fa0d2ed3 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 13 Sep 2012 15:13:45 +0000 Subject: [PATCH] PR c++/54511 * pt.c (tsubst_decl) [VAR_DECL]: Handle DECL_ANON_UNION_VAR_P. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@191262 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/pt.c | 10 ++++++++++ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/template/anonunion2.C | 6 ++++++ 4 files changed, 22 insertions(+) create mode 100644 gcc/testsuite/g++.dg/template/anonunion2.C diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b7d8a1d43d5..6d135a35b44 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2012-09-13 Jason Merrill + PR c++/54511 + * pt.c (tsubst_decl) [VAR_DECL]: Handle DECL_ANON_UNION_VAR_P. + PR c++/53836 * pt.c (value_dependent_expression_p): A TREE_LIST initializer must be dependent. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 4cf2ed8917b..5b7976ae964 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -10443,6 +10443,16 @@ tsubst_decl (tree t, tree args, tsubst_flags_t complain) break; } + if (TREE_CODE (t) == VAR_DECL && DECL_ANON_UNION_VAR_P (t)) + { + /* Just use name lookup to find a member alias for an anonymous + union, but then add it to the hash table. */ + r = lookup_name (DECL_NAME (t)); + gcc_assert (DECL_ANON_UNION_VAR_P (r)); + register_local_specialization (r, t); + break; + } + /* Create a new node for the specialization we need. */ r = copy_decl (t); if (type == NULL_TREE) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index debdd885c30..3b813a3f014 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2012-09-13 Jason Merrill + PR c++/54511 + * g++.dg/template/anonunion2.C: New. + PR c++/53836 * g++.dg/template/init10.C: New. diff --git a/gcc/testsuite/g++.dg/template/anonunion2.C b/gcc/testsuite/g++.dg/template/anonunion2.C new file mode 100644 index 00000000000..cb3c12dff1e --- /dev/null +++ b/gcc/testsuite/g++.dg/template/anonunion2.C @@ -0,0 +1,6 @@ +template +struct S +{ + S () { union { int a; }; a = 0; } +}; +S<0> s; -- 2.11.4.GIT