]> granicus.if.org Git - clang/commitdiff
fix PR3427: fix debuginfo for incomplete array types
authorNuno Lopes <nunoplopes@sapo.pt>
Wed, 28 Jan 2009 00:35:17 +0000 (00:35 +0000)
committerNuno Lopes <nunoplopes@sapo.pt>
Wed, 28 Jan 2009 00:35:17 +0000 (00:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63158 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp
test/CodeGen/debug-info.c

index e0a52d61844d595dafc123fcff1cb01cf04c7ae7..79abc340644aa803cb812f5cd09e500e0f7bda18 100644 (file)
@@ -337,11 +337,14 @@ llvm::DIType CGDebugInfo::CreateType(const ArrayType *Ty,
   uint64_t Align;
   
   
+  // FIXME: make getTypeAlign() aware of VLAs and incomplete array types
   if (const VariableArrayType *VAT = dyn_cast<VariableArrayType>(Ty)) {
-
     Size = 0;
     Align =
-      M->getContext().getTypeSize(M->getContext().getBaseElementType(VAT));
+      M->getContext().getTypeAlign(M->getContext().getBaseElementType(VAT));
+  } else if (Ty->isIncompleteArrayType()) {
+    Size = 0;
+    Align = M->getContext().getTypeAlign(Ty->getElementType());
   } else {
     // Size and align of the whole array, not the element type.
     Size = M->getContext().getTypeSize(Ty);
index f5a31631fbadcc6269824a3b4b9140907592e036..2ecae9fa6d59f541a0c52105a2e339b1b4a74916 100644 (file)
@@ -18,7 +18,13 @@ struct s0 { struct s0 *p; } g0;
 struct s0 *f0(struct s0 *a0) {
   return a0->p;
 }
-  
+
 // PR3134
 char xpto[];
 
+// PR3427
+struct foo {
+       int a;
+       void *ptrs[];
+};
+struct foo bar;