aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorAlan Zhao <ayzhao@google.com>2023-04-26 14:50:01 -0700
committerAlan Zhao <ayzhao@google.com>2023-04-27 10:43:16 -0700
commit7417e9d75c9af7dd0d3dad12eebdee84b10b56d7 (patch)
tree8d8b6be555fd629430fcf27470e6896a0708aaa2 /clang/lib/Sema/SemaInit.cpp
parent48ed7c43892bdb43e52222add97660031da4d410 (diff)
downloadllvm-7417e9d75c9af7dd0d3dad12eebdee84b10b56d7.zip
llvm-7417e9d75c9af7dd0d3dad12eebdee84b10b56d7.tar.gz
llvm-7417e9d75c9af7dd0d3dad12eebdee84b10b56d7.tar.bz2
[clang] Fix a crash with parenthesized aggregate initialization and base classes
When calling InitializeBase(...), TryOrBuidlParenListInit(...) needs to pass in the parent entity; otherwise, we erroneously try to cast CurContext to a CXXConstructorDecl[0], which can't be done since we're performing aggregate initialization, not constructor initialization. Field initialization is not affected, but this patch still adds some tests for it. Fixes 62296 [0]: https://github.com/llvm/llvm-project/blob/33d6bd1c667456f7f4a9d338a7996a30a3af50a3/clang/lib/Sema/SemaAccess.cpp#L1696 Reviewed By: aaron.ballman Differential Revision: https://reviews.llvm.org/D149301
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r--clang/lib/Sema/SemaInit.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 243c3c1..c218470 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -5449,8 +5449,9 @@ static void TryOrBuildParenListInitialization(
} else if (auto *RT = Entity.getType()->getAs<RecordType>()) {
const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
- auto BaseRange = map_range(RD->bases(), [&S](auto &base) {
- return InitializedEntity::InitializeBase(S.getASTContext(), &base, false);
+ auto BaseRange = map_range(RD->bases(), [&](auto &base) {
+ return InitializedEntity::InitializeBase(S.getASTContext(), &base, false,
+ &Entity);
});
auto FieldRange = map_range(RD->fields(), [](auto *field) {
return InitializedEntity::InitializeMember(field);