Index: SemaInit.cpp =================================================================== --- SemaInit.cpp +++ SemaInit.cpp @@ -2260,15 +2260,17 @@ assert(StructuredList->getNumInits() == 1 && "A union should never have more than one initializer!"); - // We're about to throw away an initializer, emit warning. - SemaRef.Diag(D->getFieldLoc(), - diag::warn_initializer_overrides) - << D->getSourceRange(); Expr *ExistingInit = StructuredList->getInit(0); - SemaRef.Diag(ExistingInit->getLocStart(), - diag::note_previous_initializer) - << /*FIXME:has side effects=*/0 - << ExistingInit->getSourceRange(); + if (ExistingInit) { + // We're about to throw away an initializer, emit warning. + SemaRef.Diag(D->getFieldLoc(), + diag::warn_initializer_overrides) + << D->getSourceRange(); + SemaRef.Diag(ExistingInit->getLocStart(), + diag::note_previous_initializer) + << /*FIXME:has side effects=*/0 + << ExistingInit->getSourceRange(); + } // remove existing initializer StructuredList->resizeInits(SemaRef.Context, 0); Index: sema-segvcheck.c =================================================================== --- sema-segvcheck.c +++ sema-segvcheck.c @@ -0,0 +1,50 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only %s; test $? -eq 1 + +typedef struct { + union { + unsigned long long house; + struct { + unsigned cat1; + unsigned cat2; + }; + }; +} struct_0; + + +typedef struct { + union { + struct { + union { + unsigned cows; + struct { + unsigned char c:1; + }; + }; + }; + }; + + union { + struct { + unsigned bird0; + unsigned bird1; + }; + }; +} struct_1; + + +typedef struct { + struct_0 s0; + struct_1 s1[1]; +} struct_2; + +struct_2 s = { + .s0 = { + .dog = 0x00000000, // expected-error{{field designator}} + }, + + .s1[0] = { + .cows = 0x00005050, + .c = 1, + }, +};