OSDN Git Service

Fix PR c++/42251
authordodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 Dec 2009 12:25:19 +0000 (12:25 +0000)
committerdodji <dodji@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 11 Dec 2009 12:25:19 +0000 (12:25 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155159 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/const3.C [new file with mode: 0644]

index c98e68a..19e751d 100644 (file)
@@ -1,3 +1,8 @@
+2009-12-11  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/42251
+       * pt.c (convert_template_argument): Avoid missing folding of SCOPE_REFs.
+
 2009-12-10  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/42317
index 97a2f80..6f76d46 100644 (file)
@@ -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 (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;
index d6256a3..9874446 100644 (file)
@@ -1,3 +1,8 @@
+2009-12-11  Dodji Seketeli  <dodji@redhat.com>
+
+       PR c++/42251
+       * g++.dg/template/const3.C: New test.
+
 2009-12-11  Richard Guenther  <rguenther@suse.de>
 
        PR lto/42320
diff --git a/gcc/testsuite/g++.dg/template/const3.C b/gcc/testsuite/g++.dg/template/const3.C
new file mode 100644 (file)
index 0000000..5ef2731
--- /dev/null
@@ -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>
+{
+};
+