===================================================================
@@ -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);
===================================================================
@@ -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" }