diff mbox

[C++,/,RFC] PR 50870

Message ID 4EA81BB4.8090900@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Oct. 26, 2011, 2:39 p.m. UTC
Hi,

I'm trying to fix this PR, ice on valid, which Daniel kindly filed while 
we were triaging PR50864. In short, in tsubst_copy_and_build, for 
COMPONENT_REF, we call tsubst_baselink with an object which in this case 
is an ARROW_EXPR, thus its TREE_TYPE is NULL_TREE. I'm trying to fix 
this be using the first operand instead, as we normally do for 
ARROW_EXPRs elsewhere. Note that, assuming this makes sense, we probably 
want to audit also case COMPONENT_REF in tsubst_copy...

What do you think?

(Tested already x86_64-linux)

Thanks,
Paolo.

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

	PR c++/50870
	* pt.c (tsubst_copy_and_build): When object is an ARROW_EXPR
	pass to tsubst_baselink its first operand.

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

	PR c++/50870
	* g++.dg/cpp0x/decltype34.C: New.

Comments

Jason Merrill Oct. 26, 2011, 3:27 p.m. UTC | #1
On 10/26/2011 10:39 AM, Paolo Carlini wrote:
> I'm trying to fix this PR, ice on valid, which Daniel kindly filed while
> we were triaging PR50864. In short, in tsubst_copy_and_build, for
> COMPONENT_REF, we call tsubst_baselink with an object which in this case
> is an ARROW_EXPR, thus its TREE_TYPE is NULL_TREE.

That's OK, we can pass a null type to tsubst_baselink.  Just fix 
non_reference to pass NULL_TREE through.

Jason
diff mbox

Patch

Index: testsuite/g++.dg/cpp0x/decltype34.C
===================================================================
--- testsuite/g++.dg/cpp0x/decltype34.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/decltype34.C	(revision 0)
@@ -0,0 +1,19 @@ 
+// PR c++/50870
+// { dg-options "-std=gnu++0x" }
+
+struct impl
+{
+  template <class T> static T create();
+};
+
+template<class T, class U,
+	 class = decltype(impl::create<T>()->impl::create<U>())>
+struct tester{};
+
+tester<impl*, int> ti;
+
+template<class T, class U,
+	 class = decltype(impl::create<T>()->impl::create<U>())>
+int test() { return 0; }
+
+int i = test<impl*, int>();
Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 180520)
+++ cp/pt.c	(working copy)
@@ -13711,7 +13711,9 @@  tsubst_copy_and_build (tree t,
 	member = TREE_OPERAND (t, 1);
 	if (BASELINK_P (member))
 	  member = tsubst_baselink (member,
-				    non_reference (TREE_TYPE (object)),
+				    TREE_CODE (object) == ARROW_EXPR
+				    ? TREE_OPERAND (object, 0)
+				    : non_reference (TREE_TYPE (object)),
 				    args, complain, in_decl);
 	else
 	  member = tsubst_copy (member, args, complain, in_decl);