Patchwork [C++] PR 50864

login
register
mail settings
Submitter Paolo Carlini
Date Oct. 28, 2011, 5:38 p.m.
Message ID <4EAAE8B1.6010801@oracle.com>
Download mbox | patch
Permalink /patch/122451/
State New
Headers show

Comments

Paolo Carlini - Oct. 28, 2011, 5:38 p.m.
Hi,

as per the recent discussion. This also changes c++/50870 from 
ice-on-valid to reject-valid, a *tad* better I think (but I mean to 
continue working on it, for a while). Tested x86_64-linux.

Ok for mainline?

Thanks,
Paolo.

////////////////////
/cp
2011-10-28  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/50864
	* pt.c (tsubst_copy_and_build): Fix qualified_name_lookup_error
	call in case COMPONENT_REF.

/testsuite
2011-10-28  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/50864
	* testsuite/g++.dg/template/crash109.C: New.
Jason Merrill - Oct. 28, 2011, 6:19 p.m.
OK.

Jason
Paolo Carlini - Oct. 28, 2011, 11:53 p.m.
On 10/28/2011 08:19 PM, Jason Merrill wrote:
> OK.
>
> Jason
Humpf, looks I did something wrong when testing this and now I see the 
new testcase failing. I'm going to look a bit into this, and otherwise 
in an hour or so will simply revert the whole thing.

Sorry,
Paolo.
Paolo Carlini - Oct. 29, 2011, 12:10 a.m.
On 10/29/2011 01:53 AM, Paolo Carlini wrote:
> On 10/28/2011 08:19 PM, Jason Merrill wrote:
>> OK.
>>
>> Jason
> Humpf, looks I did something wrong when testing this and now I see the 
> new testcase failing. I'm going to look a bit into this, and otherwise 
> in an hour or so will simply revert the whole thing.
I reverted it. Had inadvertently tested with checking disabled, the 
problem with checking enabled happens earlier than that.

Paolo.
Jason Merrill - Nov. 7, 2011, 8:39 p.m.
On 10/28/2011 08:10 PM, Paolo Carlini wrote:
> I reverted it. Had inadvertently tested with checking disabled, the
> problem with checking enabled happens earlier than that.

Was there a problem with the patch?  It still looks correct even if it 
doesn't fix this testcase, so there's no need to revert it.

Jason
Paolo Carlini - Nov. 7, 2011, 9:16 p.m.
On 11/07/2011 09:39 PM, Jason Merrill wrote:
> On 10/28/2011 08:10 PM, Paolo Carlini wrote:
>> I reverted it. Had inadvertently tested with checking disabled, the
>> problem with checking enabled happens earlier than that.
>
> Was there a problem with the patch?  It still looks correct even if it 
> doesn't fix this testcase, so there's no need to revert it.
Oh, thanks for paying attention to that. Sure, I can reapply it, without 
the testcase, however, because it fails when checking mode is enabled, 
because, as I briefly mentioned, the problem with an unwanted NAMESPACE 
node happens earlier in case COMPONENT_REF.

By the way, for the ice-on-invalid side of these issues - I'm not 
talking about the non-trivial reject-valid ones - I'm still wondering 
whether we couldn't reject the code much earlier (if you remember, at 
some point, I tried to even patch the parser, and apparently things were 
working, personally I wasn't able to construct snippets wrongly rejected)

Paolo.

Patch

Index: testsuite/g++.dg/template/crash109.C
===================================================================
--- testsuite/g++.dg/template/crash109.C	(revision 0)
+++ testsuite/g++.dg/template/crash109.C	(revision 0)
@@ -0,0 +1,10 @@ 
+// PR c++/50864
+
+namespace impl
+{
+  template <class T> T create();
+}
+
+template <class T, class U, __SIZE_TYPE__
+	  = sizeof(impl::create<T>() -> impl::create<U>())>  // { dg-error "not a member" } 
+struct foo;
Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 180619)
+++ cp/pt.c	(working copy)
@@ -13741,14 +13741,12 @@  tsubst_copy_and_build (tree t,
 	else if (TREE_CODE (member) == SCOPE_REF
 		 && TREE_CODE (TREE_OPERAND (member, 1)) == TEMPLATE_ID_EXPR)
 	  {
-	    tree tmpl;
-	    tree args;
-
 	    /* Lookup the template functions now that we know what the
 	       scope is.  */
-	    tmpl = TREE_OPERAND (TREE_OPERAND (member, 1), 0);
-	    args = TREE_OPERAND (TREE_OPERAND (member, 1), 1);
-	    member = lookup_qualified_name (TREE_OPERAND (member, 0), tmpl,
+	    tree scope = TREE_OPERAND (member, 0);
+	    tree tmpl = TREE_OPERAND (TREE_OPERAND (member, 1), 0);
+	    tree args = TREE_OPERAND (TREE_OPERAND (member, 1), 1);
+	    member = lookup_qualified_name (scope, tmpl,
 					    /*is_type_p=*/false,
 					    /*complain=*/false);
 	    if (BASELINK_P (member))
@@ -13762,7 +13760,7 @@  tsubst_copy_and_build (tree t,
 	      }
 	    else
 	      {
-		qualified_name_lookup_error (object_type, tmpl, member,
+		qualified_name_lookup_error (scope, tmpl, member,
 					     input_location);
 		return error_mark_node;
 	      }