[clang] Fix overly aggressive lifetime checks for parenthesized aggregate initialization
Before this patch, initialized class members would have the LifetimeKind LK_MemInitializer, which does not allow for binding a temporary to a reference. Binding to a temporary however is allowed in parenthesized aggregate initialization, even if it leads to a dangling reference. To fix this, we create a new EntityKind, EK_ParenAggInitMember, which has LifetimeKind LK_FullExpression. This patch does *not* attempt to diagnose dangling references as a result of using this feature. This patch also refactors TryOrBuildParenListInitialization(...) to accomodate creating different InitializedEntity objects. Fixes #61567 [0]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0960r3.html Reviewed By: shafik Differential Revision: https://reviews.llvm.org/D148274
Showing
- clang/docs/ReleaseNotes.rst 6 additions, 0 deletionsclang/docs/ReleaseNotes.rst
- clang/include/clang/Basic/DiagnosticSemaKinds.td 2 additions, 1 deletionclang/include/clang/Basic/DiagnosticSemaKinds.td
- clang/include/clang/Sema/Initialization.h 16 additions, 2 deletionsclang/include/clang/Sema/Initialization.h
- clang/lib/Sema/SemaAccess.cpp 2 additions, 1 deletionclang/lib/Sema/SemaAccess.cpp
- clang/lib/Sema/SemaInit.cpp 200 additions, 133 deletionsclang/lib/Sema/SemaInit.cpp
- clang/test/CodeGen/paren-list-agg-init.cpp 69 additions, 0 deletionsclang/test/CodeGen/paren-list-agg-init.cpp
- clang/test/SemaCXX/paren-list-agg-init.cpp 52 additions, 9 deletionsclang/test/SemaCXX/paren-list-agg-init.cpp
Loading
Please register or sign in to comment