Fix crash on invalid in microsoft anonymous struct extension.

Fixes PR11847. Patch from Jason Haslam!

llvm-svn: 149460
This commit is contained in:
Nico Weber 2012-02-01 00:41:00 +00:00
parent 3b22c6c395
commit f8bb3de488
2 changed files with 14 additions and 4 deletions

View File

@ -2952,9 +2952,10 @@ Decl *Sema::BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS,
SmallVector<NamedDecl*, 2> Chain;
Chain.push_back(Anon);
if (InjectAnonymousStructOrUnionMembers(*this, S, CurContext,
Record->getDefinition(),
AS_none, Chain, true))
RecordDecl *RecordDef = Record->getDefinition();
if (!RecordDef || InjectAnonymousStructOrUnionMembers(*this, S, CurContext,
RecordDef, AS_none,
Chain, true))
Anon->setInvalidDecl();
return Anon;

View File

@ -86,4 +86,13 @@ void pointer_to_integral_type_conv(char* ptr) {
short sh = (short)ptr;
ch = (char)ptr;
sh = (short)ptr;
}
}
typedef struct {
UNKNOWN u; // expected-error {{unknown type name 'UNKNOWN'}}
} AA;
typedef struct {
AA; // expected-warning {{anonymous structs are a Microsoft extension}}
} BB;