Fix crash on invalid initialization with std::initializer_list

It is possible for CheckListElementTypes to fail without filling in any
initializer list elements.

llvm-svn: 255176
This commit is contained in:
Reid Kleckner
2015-12-09 23:18:38 +00:00
parent 5d2f7cfd44
commit 4a09e8872f
2 changed files with 27 additions and 1 deletions

View File

@@ -805,7 +805,8 @@ void InitListChecker::CheckImplicitInitList(const InitializedEntity &Entity,
unsigned EndIndex = (Index == StartIndex? StartIndex : Index - 1);
// Update the structured sub-object initializer so that it's ending
// range corresponds with the end of the last initializer it used.
if (EndIndex < ParentIList->getNumInits()) {
if (EndIndex < ParentIList->getNumInits() &&
ParentIList->getInit(EndIndex)) {
SourceLocation EndLoc
= ParentIList->getInit(EndIndex)->getSourceRange().getEnd();
StructuredSubobjectInitList->setRBraceLoc(EndLoc);