summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprConstant.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-01-28 23:36:17 +0000
committerDouglas Gregor <dgregor@apple.com>2009-01-28 23:36:17 +0000
commit17bd094a6b0bffdb578a8ab19cd92e8cdaba8f61 (patch)
tree577e5b22318c8ac4a8025920e780ddd3671cbf96 /clang/lib/CodeGen/CGExprConstant.cpp
parent9150f735fa3180c3985c12456856a7cede64b82e (diff)
downloadbcm5719-llvm-17bd094a6b0bffdb578a8ab19cd92e8cdaba8f61.tar.gz
bcm5719-llvm-17bd094a6b0bffdb578a8ab19cd92e8cdaba8f61.zip
Improvements to code-generation and semantic analysis of designated
initializers. - We now initialize unions properly when a member other than the first is named by a designated initializer. - We now provide proper semantic analysis and code generation for GNU array-range designators *except* that side effects will occur more than once. We warn about this. llvm-svn: 63253
Diffstat (limited to 'clang/lib/CodeGen/CGExprConstant.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprConstant.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index 87868ed347a..b05048c9460 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -246,12 +246,22 @@ public:
// first field
int FieldNo = 0; // Field no in RecordDecl
FieldDecl* curField = 0;
+ bool sawAnyFields = false;
for (RecordDecl::field_iterator Field = RD->field_begin(),
FieldEnd = RD->field_end();
Field != FieldEnd; ++Field) {
curField = *Field;
FieldNo++;
- if (curField->getIdentifier())
+
+ if (curField->isUnnamedBitfield())
+ continue;
+
+ // If we have an initializer, find the field whose type is the
+ // same as that initializer. This
+ sawAnyFields = true;
+ if (ILE->getNumInits() > 0 &&
+ CGM.getContext().getCanonicalType(curField->getType()) ==
+ CGM.getContext().getCanonicalType(ILE->getInit(0)->getType()))
break;
}
OpenPOWER on IntegriCloud