aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-05-08 21:04:47 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-05-08 21:04:47 +0000
commitfcab2ca966d5176839f8698535e0d807bd968629 (patch)
treeab5f682423710f27de9751be852b134465446818
parenteedd292ea0cf2216ff16d3490147323489102e3a (diff)
Darwin x86_32: Ignore padding bit-fields when looking for "single
element" structures. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71266 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/CGCall.cpp12
-rw-r--r--test/CodeGen/x86_32-arguments.c3
2 files changed, 11 insertions, 4 deletions
diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp
index eba5ff5b5e..883eb5ede4 100644
--- a/lib/CodeGen/CGCall.cpp
+++ b/lib/CodeGen/CGCall.cpp
@@ -204,11 +204,15 @@ static const Type *isSingleElementStruct(QualType T, ASTContext &Context) {
if (AT->getSize().getZExtValue() == 1)
FT = AT->getElementType();
- if (isEmptyRecord(Context, FT)) {
- // Ignore
- } else if (Found) {
+ // Ignore empty records and padding bit-fields.
+ if (isEmptyRecord(Context, FT) ||
+ (FD->isBitField() && !FD->getIdentifier()))
+ continue;
+
+ if (Found)
return 0;
- } else if (!CodeGenFunction::hasAggregateLLVMType(FT)) {
+
+ if (!CodeGenFunction::hasAggregateLLVMType(FT)) {
Found = FT.getTypePtr();
} else {
Found = isSingleElementStruct(FT, Context);
diff --git a/test/CodeGen/x86_32-arguments.c b/test/CodeGen/x86_32-arguments.c
index b18d2d0acb..c75734e5a1 100644
--- a/test/CodeGen/x86_32-arguments.c
+++ b/test/CodeGen/x86_32-arguments.c
@@ -130,4 +130,7 @@ struct s29 { struct { } a[1]; char b; char c; } f29(void) {}
// RUN: grep 'define i16 @f30()' %t &&
struct s30 { char a; char b : 4; } f30(void) {}
+// RUN: grep 'define float @f31()' %t &&
+struct s31 { char : 0; float b; char : 0} f31(void) {}
+
// RUN: true