summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2009-09-13 17:55:13 +0000
committerAnders Carlsson <andersca@mac.com>2009-09-13 17:55:13 +0000
commitccbabc9645329bbb05b8fc3d50c694f28f284698 (patch)
tree64dee13356b8169af6a9b179108c2d303cf657b3 /clang
parent512e60ac35a6e2b39fd1488cc5eb43cdf495e365 (diff)
downloadbcm5719-llvm-ccbabc9645329bbb05b8fc3d50c694f28f284698.tar.gz
bcm5719-llvm-ccbabc9645329bbb05b8fc3d50c694f28f284698.zip
Fix another byref bug. This should hopefully get QuickLookPlugins building successfully.
llvm-svn: 81681
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp20
-rw-r--r--clang/test/CodeGen/blocks-aligned-byref-variable.c10
2 files changed, 19 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 926e5c6686e..31e74f05e46 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -270,18 +270,18 @@ const llvm::Type *CodeGenFunction::BuildByRefType(const ValueDecl *D) {
llvm::RoundUpToAlignment(CurrentOffsetInBytes, Align);
unsigned NumPaddingBytes = AlignedOffsetInBytes - CurrentOffsetInBytes;
- assert(NumPaddingBytes > 0 && "Can't append any padding!");
+ if (NumPaddingBytes > 0) {
+ const llvm::Type *Ty = llvm::Type::getInt8Ty(VMContext);
+ // FIXME: We need a sema error for alignment larger than the minimum of the
+ // maximal stack alignmint and the alignment of malloc on the system.
+ if (NumPaddingBytes > 1)
+ Ty = llvm::ArrayType::get(Ty, NumPaddingBytes);
- const llvm::Type *Ty = llvm::Type::getInt8Ty(VMContext);
- // FIXME: We need a sema error for alignment larger than the minimum of the
- // maximal stack alignmint and the alignment of malloc on the system.
- if (NumPaddingBytes > 1)
- Ty = llvm::ArrayType::get(Ty, NumPaddingBytes);
-
- Types.push_back(Ty);
+ Types.push_back(Ty);
- // We want a packed struct.
- Packed = true;
+ // We want a packed struct.
+ Packed = true;
+ }
}
// T x;
diff --git a/clang/test/CodeGen/blocks-aligned-byref-variable.c b/clang/test/CodeGen/blocks-aligned-byref-variable.c
index 975c03a43c1..1ae30625415 100644
--- a/clang/test/CodeGen/blocks-aligned-byref-variable.c
+++ b/clang/test/CodeGen/blocks-aligned-byref-variable.c
@@ -1,4 +1,5 @@
-// RUN: clang-cc -emit-llvm -o -
+// RUN: clang-cc -emit-llvm -o - -triple x86_64-apple-darwin10 &&
+// RUN: clang-cc -emit-llvm -o - -triple i386-apple-darwin10
typedef int __attribute__((aligned(32))) ai;
void f() {
@@ -9,3 +10,10 @@ void f() {
}();
}
+void g() {
+ __block double a = 10;
+
+ ^{
+ a = 20;
+ }();
+}
OpenPOWER on IntegriCloud