Hi,
in this ICE on invalid, during error recovery resolve_typename_type gets
a TYPE which has a DECLTYPE_TYPE as TYPE_CONTEXT and
CLASSTYPE_PRIMARY_TEMPLATE_TYPE ICEs on the latter. Checking
CLASS_TYPE_P and thus returning the TYPE as is avoids the ICE and passes
testing on x86_64-linux.
Thanks,
Paolo.
///////////////////////////////
/cp
2015-08-13 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/63693
* pt.c (resolve_typename_type): Don't use
CLASSTYPE_PRIMARY_TEMPLATE_TYPE on non-CLASS_TYPE_P.
/testsuite
2015-08-13 Paolo Carlini <paolo.carl...@oracle.com>
PR c++/63693
* g++.dg/cpp0x/decltype63.C: New.
Index: cp/pt.c
===================================================================
--- cp/pt.c (revision 226855)
+++ cp/pt.c (working copy)
@@ -22669,7 +22669,8 @@ resolve_typename_type (tree type, bool only_curren
return type;
/* If SCOPE isn't the template itself, it will not have a valid
TYPE_FIELDS list. */
- if (same_type_p (scope, CLASSTYPE_PRIMARY_TEMPLATE_TYPE (scope)))
+ if (CLASS_TYPE_P (scope)
+ && same_type_p (scope, CLASSTYPE_PRIMARY_TEMPLATE_TYPE (scope)))
/* scope is either the template itself or a compatible instantiation
like X<T>, so look up the name in the original template. */
scope = CLASSTYPE_PRIMARY_TEMPLATE_TYPE (scope);
Index: testsuite/g++.dg/cpp0x/decltype63.C
===================================================================
--- testsuite/g++.dg/cpp0x/decltype63.C (revision 0)
+++ testsuite/g++.dg/cpp0x/decltype63.C (working copy)
@@ -0,0 +1,7 @@
+// PR c++/63693
+// { dg-do compile { target c++11 } }
+
+template<typename T>
+class C{
+ T t;
+ decltype(t)::a:: // { dg-error "expected" }