aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2009-01-28 00:35:17 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2009-01-28 00:35:17 +0000
commit010d5143800f6dc986f90169a694ccfec3d52038 (patch)
treece1eeb04a790b4afdf271b51a7e5df14d58478e4
parentcb8d58b82859d2c56b679b901de38f416e2b6f48 (diff)
fix PR3427: fix debuginfo for incomplete array types
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63158 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGDebugInfo.cpp7
-rw-r--r--test/CodeGen/debug-info.c8
2 files changed, 12 insertions, 3 deletions
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index e0a52d6184..79abc34064 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -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);
diff --git a/test/CodeGen/debug-info.c b/test/CodeGen/debug-info.c
index f5a31631fb..2ecae9fa6d 100644
--- a/test/CodeGen/debug-info.c
+++ b/test/CodeGen/debug-info.c
@@ -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;