[PATCH] D149301: [clang] Fix a crash with parenthesized aggregate initialization and base classes
Alan Zhao via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 27 10:43:06 PDT 2023
ayzhao updated this revision to Diff 517636.
ayzhao added a comment.
add release note
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149301/new/
https://reviews.llvm.org/D149301
Files:
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaInit.cpp
clang/test/SemaCXX/paren-list-agg-init.cpp
Index: clang/test/SemaCXX/paren-list-agg-init.cpp
===================================================================
--- clang/test/SemaCXX/paren-list-agg-init.cpp
+++ clang/test/SemaCXX/paren-list-agg-init.cpp
@@ -200,3 +200,26 @@
// expected-error at -1 {{call to implicitly-deleted copy constructor of 'V'}}
}
}
+
+namespace gh62296 {
+struct L {
+protected:
+ L(int);
+ // expected-note at -1 2{{declared protected here}}
+};
+
+struct M : L {};
+
+struct N {
+ L l;
+};
+
+M m(42);
+// expected-error at -1 {{base class 'L' has protected constructor}}
+// beforecxx20-warning at -2 {{aggregate initialization of type 'M' from a parenthesized list of values is a C++20 extension}}
+
+N n(43);
+// expected-error at -1 {{field of type 'L' has protected constructor}}
+// beforecxx20-warning at -2 {{aggregate initialization of type 'N' from a parenthesized list of values is a C++20 extension}}
+
+}
Index: clang/lib/Sema/SemaInit.cpp
===================================================================
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -5449,8 +5449,9 @@
} 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);
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -331,6 +331,9 @@
constructor declaration.
(`#62361 <https://github.com/llvm/llvm-project/issues/62361>`_)
(`#62362 <https://github.com/llvm/llvm-project/issues/62362>`_)
+- Fix crash when attempting to perform parenthesized initialization of an
+ aggregate with a base class with only non-public constructors.
+ (`#62296 <https://github.com/llvm/llvm-project/issues/62296 >`_)
Bug Fixes to Compiler Builtins
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149301.517636.patch
Type: text/x-patch
Size: 2322 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230427/058d3928/attachment.bin>
More information about the cfe-commits
mailing list