Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -14475,7 +14475,7 @@ case Stmt::MemberExprClass: { auto *ME = cast(E); auto *FD = dyn_cast(ME->getMemberDecl()); - if (!FD || FD->getType()->isReferenceType()) + if (!FD || FD->getType()->isReferenceType() || FD->getParent()->isInvalidDecl()) break; Optional> P; if (ME->isArrow()) Index: clang/test/Sema/warn-cast-align.c =================================================================== --- clang/test/Sema/warn-cast-align.c +++ clang/test/Sema/warn-cast-align.c @@ -67,3 +67,9 @@ FnTy test5(void) { return (FnTy)&func5; } + + +void test6() { + struct { int hello; doesnotexist world; } foo; // expected-error {{unknown type name 'doesnotexist'}} + void** repro = (void**)&foo.hello; // expected-warning {{cast from 'int *' to 'void **' increases required alignment from 4 to 8}} +}