diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2008-06-06 20:12:37 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2008-06-06 20:12:37 +0000 |
commit | c55f98dbdffb73894a8dbe7b0ce176604fe42127 (patch) | |
tree | c2a5aadba4c059238eceb9bca7d8112b29e14bd4 /lib/CodeGen/CGExprConstant.cpp | |
parent | 400d95fb7bb9fac609f8613862b84f3a2a7d510f (diff) |
Reorganize this loop a bit so it doesn't crash for empty unions. Fixes
PR2419.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52060 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprConstant.cpp')
-rw-r--r-- | lib/CodeGen/CGExprConstant.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 58b1884817..f5977728af 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -213,13 +213,15 @@ public: // Find the field decl we're initializing, if any int FieldNo = 0; // Field no in RecordDecl - FieldDecl* curField; - do { + FieldDecl* curField = 0; + while (FieldNo < RD->getNumMembers()) { curField = RD->getMember(FieldNo); FieldNo++; - } while (!curField->getIdentifier() && FieldNo < RD->getNumMembers()); + if (curField->getIdentifier()) + break; + } - if (ILE->getNumInits() == 0 || !curField->getIdentifier()) + if (!curField || !curField->getIdentifier() || ILE->getNumInits() == 0) return llvm::Constant::getNullValue(Ty); if (curField->isBitField()) { |