diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-07-17 23:12:06 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2014-07-17 23:12:06 +0000 |
| commit | 8aa561ba328d84dd0bdb4bb64688fc24e4f3f428 (patch) | |
| tree | 3638e1284ed1c829bc586815eab4c8815d928923 /clang/lib/Sema | |
| parent | e5fc826f8876fc10308745833d94dcd428ffcb83 (diff) | |
| download | bcm5719-llvm-8aa561ba328d84dd0bdb4bb64688fc24e4f3f428.tar.gz bcm5719-llvm-8aa561ba328d84dd0bdb4bb64688fc24e4f3f428.zip | |
PR20346: fix aggregate initialization / template instantiation bug:
If, during the initial parse of a template, we perform aggregate initialization
and form an implicit value initialization for an array type, then when we come
to instantiate the template and redo the initialization step, we would try to
match the implicit value initialization up against an array *element*, not to
the complete array.
Remarkably, we've had this bug since ~the dawn of time, but only noticed it
recently.
llvm-svn: 213332
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 4b756064add..3ed1d7f1f66 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -914,6 +914,15 @@ void InitListChecker::CheckSubElementType(const InitializedEntity &Entity, assert(SemaRef.getLangOpts().CPlusPlus && "non-aggregate records are only possible in C++"); // C++ initialization is handled later. + } else if (auto *VIE = dyn_cast<ImplicitValueInitExpr>(expr)) { + // This happens during template instantiation when we see an InitListExpr + // that we've already checked once. + assert(SemaRef.Context.hasSameType(VIE->getType(), ElemType) && + "found implicit initialization for the wrong type"); + if (!VerifyOnly) + UpdateStructuredListElement(StructuredList, StructuredIndex, expr); + ++Index; + return; } // FIXME: Need to handle atomic aggregate types with implicit init lists. |

