From 9d84dbe6bacebc8f947cc0bb2bffe86fd8aeb5f0 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 26 Sep 2011 22:13:00 -0400 Subject: re PR c++/45012 (Invalid ambiguity on partial class specialization matching) PR c++/45102 * pt.c (tsubst_copy_and_build) [CONST_DECL]: Don't pull out constant value if we're still in a template. From-SVN: r179230 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/pt.c | 2 +- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/template/partial13.C | 25 +++++++++++++++++++++++++ 4 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/template/partial13.C (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index abde58c..22f3dde 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2011-09-26 Jason Merrill + PR c++/45102 + * pt.c (tsubst_copy_and_build) [CONST_DECL]: Don't pull out + constant value if we're still in a template. + PR c++/46105 * typeck.c (structural_comptypes): Ignore cv-quals on typename scope. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index cac45f9..4d57f94 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -13916,7 +13916,7 @@ tsubst_copy_and_build (tree t, t = tsubst_copy (t, args, complain, in_decl); /* As in finish_id_expression, we resolve enumeration constants to their underlying values. */ - if (TREE_CODE (t) == CONST_DECL) + if (TREE_CODE (t) == CONST_DECL && !processing_template_decl) { used_types_insert (TREE_TYPE (t)); return DECL_INITIAL (t); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 32cf960..3c12f61 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2011-09-26 Jason Merrill + PR c++/45012 + * g++.dg/template/partial13.C: New. + PR c++/46105 * g++.dg/template/partial12.C: New. diff --git a/gcc/testsuite/g++.dg/template/partial13.C b/gcc/testsuite/g++.dg/template/partial13.C new file mode 100644 index 0000000..bfbe2e0 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/partial13.C @@ -0,0 +1,25 @@ +// PR c++/45012 + +template struct enable_if; + +template +struct enable_if +{ + typedef T type; +}; + +enum { RUNTIME = 0 }; +// it compiles with the previous line commented out and the next commented in +// static const int RUNTIME=0; + +template struct foo; + +template class V, int M> +struct foo,V, typename enable_if::type> {}; + +template class V1, template class V2, int M> +struct foo,V2, typename enable_if::type> {}; + +template struct bar {}; + +foo,bar<2> > x; -- cgit v1.1