From: John McCall Date: Thu, 22 Oct 2009 23:31:08 +0000 (+0000) Subject: Preserve source information for anonymous struct/union declarations. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=eb692e07c71be22d06d38c83ad081a3808bd7f2a;p=clang Preserve source information for anonymous struct/union declarations. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84913 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 5b9fdf8aea..b83181becb 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1529,14 +1529,19 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, Invalid = true; } + // Mock up a declarator. + Declarator Dc(DS, Declarator::TypeNameContext); + DeclaratorInfo *DInfo = 0; + GetTypeForDeclarator(Dc, S, &DInfo); + assert(DInfo && "couldn't build declarator info for anonymous struct/union"); + // Create a declaration for this anonymous struct/union. NamedDecl *Anon = 0; if (RecordDecl *OwningClass = dyn_cast(Owner)) { Anon = FieldDecl::Create(Context, OwningClass, Record->getLocation(), /*IdentifierInfo=*/0, Context.getTypeDeclType(Record), - // FIXME: Type source info. - /*DInfo=*/0, + DInfo, /*BitWidth=*/0, /*Mutable=*/false); Anon->setAccess(AS_public); if (getLangOptions().CPlusPlus) @@ -1563,8 +1568,7 @@ Sema::DeclPtrTy Sema::BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, Anon = VarDecl::Create(Context, Owner, Record->getLocation(), /*IdentifierInfo=*/0, Context.getTypeDeclType(Record), - // FIXME: Type source info. - /*DInfo=*/0, + DInfo, SC); } Anon->setImplicit();