diff mbox

[C++] PR 63693

Message ID 55CC92CC.1010304@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Aug. 13, 2015, 12:51 p.m. UTC
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.carlini@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.carlini@oracle.com>

	PR c++/63693
	* g++.dg/cpp0x/decltype63.C: New.

Comments

Jason Merrill Aug. 22, 2015, 2:58 p.m. UTC | #1
OK.

Jason
diff mbox

Patch

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" }