Index: lib/Sema/SemaExprCXX.cpp =================================================================== --- lib/Sema/SemaExprCXX.cpp +++ lib/Sema/SemaExprCXX.cpp @@ -96,7 +96,8 @@ return ParsedType::make(T); } - if (SS.isNotEmpty() && RequireCompleteDeclContext(SS, CurClass)) + if ((SS.isNotEmpty() && RequireCompleteDeclContext(SS, CurClass)) || + CurClass->isInvalidDecl()) return ParsedType(); // Find the injected-class-name declaration. Note that we make no attempt to Index: test/Sema/injected-class-name-crash.cpp =================================================================== --- /dev/null +++ test/Sema/injected-class-name-crash.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +template +struct X : public Foo +X::X() { +}