]> granicus.if.org Git - clang/commitdiff
Preserve source information for anonymous struct/union declarations.
authorJohn McCall <rjmccall@apple.com>
Thu, 22 Oct 2009 23:31:08 +0000 (23:31 +0000)
committerJohn McCall <rjmccall@apple.com>
Thu, 22 Oct 2009 23:31:08 +0000 (23:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84913 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp

index 5b9fdf8aeadbcc2d9472bf35db26371525416a4e..b83181becb93c567f3b3f27d057192b08104d3d2 100644 (file)
@@ -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();