Index: lib/Sema/SemaCXXScopeSpec.cpp =================================================================== --- lib/Sema/SemaCXXScopeSpec.cpp +++ lib/Sema/SemaCXXScopeSpec.cpp @@ -1054,7 +1054,12 @@ // it is a complete declaration context. if (!DC->isDependentContext() && RequireCompleteDeclContext(SS, DC)) return true; - + + // Don't enter a declarator context when the current context is an Objective-C + // declaration as we might no be able to restore it when exiting the scope. + if (isa(CurContext) || isa(CurContext)) + return true; + EnterDeclaratorContext(S, DC); // Rebuild the nested name specifier for the new scope. Index: test/SemaObjCXX/crash.mm =================================================================== --- test/SemaObjCXX/crash.mm +++ test/SemaObjCXX/crash.mm @@ -25,3 +25,17 @@ // expected-warning@-2 {{variadic templates are a C++11 extension}} #endif @end + +// rdar://20560175 + +struct OuterType { + typedef int InnerType; +}; + +@protocol InvalidProperty +@property (nonatomic) (OuterType::InnerType) invalidTypeParens; +// expected-error@-1 {{type name requires a specifier or qualifier}} +// expected-error@-2 {{expected ';' at end of declaration list}} +// expected-error@-3 {{C++ requires a type specifier for all declarations}} +// expected-error@-4 {{cannot declare variable inside @interface or @protocol}} +@end