Index: cfe/trunk/lib/Sema/SemaChecking.cpp =================================================================== --- cfe/trunk/lib/Sema/SemaChecking.cpp +++ cfe/trunk/lib/Sema/SemaChecking.cpp @@ -12097,6 +12097,8 @@ if (ME->isArrow()) BaseType = BaseType->getPointeeType(); RecordDecl *RD = BaseType->getAs()->getDecl(); + if (RD->isInvalidDecl()) + return; ValueDecl *MD = ME->getMemberDecl(); auto *FD = dyn_cast(MD); Index: cfe/trunk/test/Sema/address-packed.c =================================================================== --- cfe/trunk/test/Sema/address-packed.c +++ cfe/trunk/test/Sema/address-packed.c @@ -329,3 +329,12 @@ uint32_t *p32; p32 = &a[0].x; // no-warning } + +struct Invalid0 { + void *x; + struct fwd f; // expected-error {{incomplete type}} expected-note {{forward declaration}} +} __attribute__((packed)); + +void *g14(struct Invalid0 *ivl) { + return &(ivl->x); +}