diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-01-03 19:23:18 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-01-03 19:23:18 +0000 |
commit | 9a7d57d57f50357f138d46f9aa36e29609205d40 (patch) | |
tree | 6f180878fbf5a04479e4b9ee4c9b0015e36c5b54 /clang | |
parent | a3efea1881cd7cf7b7764b3100901b27ac2affe7 (diff) | |
download | bcm5719-llvm-9a7d57d57f50357f138d46f9aa36e29609205d40.tar.gz bcm5719-llvm-9a7d57d57f50357f138d46f9aa36e29609205d40.zip |
Consider zero-length array of structs when
computing ivar layouts for objc-gc.
Fixes // rdar://8800513
llvm-svn: 122762
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/CodeGen/CGObjCMac.cpp | 2 | ||||
-rw-r--r-- | clang/test/CodeGenObjC/ivar-layout-array0-struct.m | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp index 66913c8ee28..2a27e919250 100644 --- a/clang/lib/CodeGen/CGObjCMac.cpp +++ b/clang/lib/CodeGen/CGObjCMac.cpp @@ -3681,7 +3681,7 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCImplementationDecl *OI, assert(!FQT->isUnionType() && "layout for array of unions not supported"); - if (FQT->isRecordType()) { + if (FQT->isRecordType() && ElCount) { int OldIndex = IvarsInfo.size() - 1; int OldSkIndex = SkipIvars.size() -1; diff --git a/clang/test/CodeGenObjC/ivar-layout-array0-struct.m b/clang/test/CodeGenObjC/ivar-layout-array0-struct.m new file mode 100644 index 00000000000..4300db36415 --- /dev/null +++ b/clang/test/CodeGenObjC/ivar-layout-array0-struct.m @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin -O0 -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s + +// rdar://8800513 +@interface NSObject { + id isa; +} +@end + +typedef struct { + id b; +} st; + +@interface Test : NSObject { + int a; + st b[0]; +} +@end + +@implementation Test @end +// CHECK-LP64: L_OBJC_CLASS_NAME_4: +// CHECK-LP64-NEXT: .asciz "\001\020" |