diff mbox

C++ PATCH for c++/50870 (ICE with -> X::Y in a template default argument)

Message ID 4EB8606B.8080607@redhat.com
State New
Headers show

Commit Message

Jason Merrill Nov. 7, 2011, 10:49 p.m. UTC
Dodji's work on template parameter lists of different lengths exposed a 
problem whereby we weren't handling partial instantiation of a 
COMPONENT_REF where the member is a SCOPE_REF.  Fixed by not messing 
with it when the object is still dependent.

Tested x86_64-pc-linux-gnu, applying to trunk.

Comments

Paolo Carlini Nov. 7, 2011, 11:15 p.m. UTC | #1
On 11/07/2011 11:49 PM, Jason Merrill wrote:
> Dodji's work on template parameter lists of different lengths exposed 
> a problem whereby we weren't handling partial instantiation of a 
> COMPONENT_REF where the member is a SCOPE_REF.  Fixed by not messing 
> with it when the object is still dependent.
>
> Tested x86_64-pc-linux-gnu, applying to trunk.

Thanks. This also implies that we don't ICE anymore on c++/50864, we 
just accept it, as uninstiantiated template. I guess being able to 
reject it early at parsing time would still be a good idea, in general.

Paolo.
Jason Merrill Nov. 8, 2011, 12:47 a.m. UTC | #2
On 11/07/2011 06:15 PM, Paolo Carlini wrote:
> Thanks. This also implies that we don't ICE anymore on c++/50864, we
> just accept it, as uninstiantiated template. I guess being able to
> reject it early at parsing time would still be a good idea, in general.

Agreed.

Jason
diff mbox

Patch

commit eeb195f0839f33c5ace186a66bdc56188eb194be
Author: Jason Merrill <jason@redhat.com>
Date:   Mon Nov 7 16:50:08 2011 -0500

    	PR c++/50870
    	* pt.c (tsubst_copy): Handle NAMESPACE_DECL.
    	(tsubst_copy_and_build) [COMPONENT_REF]: Handle a still-dependent
    	object.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index c4f4a94..53a5358 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -12010,6 +12010,9 @@  tsubst_copy (tree t, tree args, tsubst_flags_t complain, tree in_decl)
       mark_used (t);
       return t;
 
+    case NAMESPACE_DECL:
+      return t;
+
     case OVERLOAD:
       /* An OVERLOAD will always be a non-dependent overload set; an
 	 overload set from function scope will just be represented with an
@@ -13871,7 +13874,9 @@  tsubst_copy_and_build (tree t,
 	if (member == error_mark_node)
 	  return error_mark_node;
 
-	if (object_type && !CLASS_TYPE_P (object_type))
+	if (type_dependent_expression_p (object))
+	  /* We can't do much here.  */;
+	else if (!CLASS_TYPE_P (object_type))
 	  {
 	    if (SCALAR_TYPE_P (object_type))
 	      {
diff --git a/gcc/testsuite/g++.dg/cpp0x/decltype35.C b/gcc/testsuite/g++.dg/cpp0x/decltype35.C
new file mode 100644
index 0000000..d1fd476
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/decltype35.C
@@ -0,0 +1,15 @@ 
+// PR c++/50870
+// { dg-options -std=c++0x }
+
+template <class V>
+  struct impl
+  {
+    template <class T> static T create();
+  };
+
+template <class T, class U, class V, class
+      = decltype(impl<V>::template create<T>()
+             -> impl<V>::template create<U>())>
+struct tester { };
+
+tester<impl<float>*, int, float> ti;