[PATCH] D156032: Implement CWG2137 (list-initialization from objects of the same type)

Mital Ashok via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Jul 23 11:01:15 PDT 2023


MitalAshok added inline comments.


================
Comment at: clang/lib/Sema/SemaInit.cpp:4249-4250
           InitializedEntity::EK_LambdaToBlockConversionBlockElement &&
-      UnwrappedArgs.size() == 1 && UnwrappedArgs[0]->isPRValue() &&
-      S.Context.hasSameUnqualifiedType(UnwrappedArgs[0]->getType(), DestType)) {
+      Args.size() == 1 && Args[0]->isPRValue() &&
+      S.Context.hasSameUnqualifiedType(Args[0]->getType(), DestType)) {
     // Convert qualifications if necessary.
----------------
MitalAshok wrote:
> This change unfortunately exposes the still-open [[ https://wg21.link/CWG2311 | CWG2311 ]] but allows `T{ object_of_type_T }` to consider user declared constructors.
> 
> I am working on a separate fix for CWG2311 (Consider constructors as below, but then if the chosen constructor is not an initializer-list constructor, elide it).
> 
Fix will be here: https://reviews.llvm.org/D156062

`auto{ prvalue }` will elide a copy for aggregate types again. It will do so after checking constructors for non-aggregate classes now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156032/new/

https://reviews.llvm.org/D156032



More information about the cfe-commits mailing list