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.carl...@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.carl...@oracle.com>

        PR c++/50870
        * g++.dg/cpp0x/decltype34.C: New.
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);

Reply via email to