On 10/26/2011 05:27 PM, Jason Merrill wrote:
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.
Ah, very good (just read the comment preceding tsubst_baselink, should
have done it earlier today ;) Thus I'm finishing testing the below, Ok
if it passes?
Thanks,
Paolo.
/////////////////////////
/cp
2011-10-26 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/50870
* typeck.c (non_reference): Pass NULL_TREE through.
/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/typeck.c
===================================================================
--- cp/typeck.c (revision 180528)
+++ cp/typeck.c (working copy)
@@ -8322,7 +8322,7 @@ casts_away_constness (tree t1, tree t2)
tree
non_reference (tree t)
{
- if (TREE_CODE (t) == REFERENCE_TYPE)
+ if (t && TREE_CODE (t) == REFERENCE_TYPE)
t = TREE_TYPE (t);
return t;
}