This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] PR c++/42251
On Tue, Dec 08, 2009 at 11:11:50AM -0500, Jason Merrill wrote:
> On 12/08/2009 10:50 AM, Dodji Seketeli wrote:
> Why not just move it inside the 'else' block? We don't need it for the
> is_type case.
The updated patch below does that.
Tested against trunk on x86_64-unknown-linux-gnu.
Thanks.
Dodji
commit 636909ca3120fdb6bb5d832f50367fa8ed47f81a
Author: Dodji Seketeli <dodji@redhat.com>
Date: Tue Dec 8 15:36:50 2009 +0100
Fix PR c++/42251
gcc/cp/ChangeLog:
PR c++/42251
* pt.c (convert_template_argument): Avoid missing folding of SCOPE_REFs.
gcc/testsuite/ChangeLog:
PR c++/42251
* g++.dg/template/const3.C: New test.
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 97a2f80..4128ad0 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -5526,13 +5526,6 @@ convert_template_argument (tree parm,
if (TYPE_P (val))
val = strip_typedefs (val);
}
- else if (TREE_CODE (orig_arg) == SCOPE_REF)
- {
- /* Strip typedefs from the SCOPE_REF. */
- tree type = strip_typedefs (TREE_TYPE (orig_arg));
- tree scope = strip_typedefs (TREE_OPERAND (orig_arg, 0));
- val = build2 (SCOPE_REF, type, scope, TREE_OPERAND (orig_arg, 1));
- }
else
{
tree t = tsubst (TREE_TYPE (parm), args, complain, in_decl);
@@ -5571,6 +5564,15 @@ convert_template_argument (tree parm,
val = error_mark_node;
else if (val == error_mark_node && (complain & tf_error))
error ("could not convert template argument %qE to %qT", orig_arg, t);
+
+ if (val && TREE_CODE (val) == SCOPE_REF)
+ {
+ /* Strip typedefs from the SCOPE_REF. */
+ tree type = strip_typedefs (TREE_TYPE (val));
+ tree scope = strip_typedefs (TREE_OPERAND (val, 0));
+ val = build_qualified_name (type, scope, TREE_OPERAND (val, 1),
+ QUALIFIED_NAME_IS_TEMPLATE (val));
+ }
}
return val;
diff --git a/gcc/testsuite/g++.dg/template/const3.C b/gcc/testsuite/g++.dg/template/const3.C
new file mode 100644
index 0000000..5ef2731
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/const3.C
@@ -0,0 +1,20 @@
+// Contributed by Dodji Seketeli <dodji@redhat.com>
+// Origin PR c++/42251
+// { dg-do "compile" }
+
+struct foo
+{
+ static const bool b = false;
+};
+
+template<bool x>
+struct S1
+{
+};
+
+template<bool x>
+struct S2
+ : S1<foo::b>
+{
+};
+