aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2009-10-22 23:31:08 +0000
committerJohn McCall <rjmccall@apple.com>2009-10-22 23:31:08 +0000
commiteb692e07c71be22d06d38c83ad081a3808bd7f2a (patch)
tree5cd8c5f1dfc1362f20db18eded28c198339d9196 /lib/Sema/SemaDecl.cpp
parent8bfd31f9dad09cd52225d868bbd92a9bebe87775 (diff)
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
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp12
1 files changed, 8 insertions, 4 deletions
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<RecordDecl>(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();