[all-commits] [llvm/llvm-project] a760df: [Clang] Implement CWG2137 (list-initialization fro...

Mital Ashok via All-commits all-commits at lists.llvm.org
Thu Aug 8 08:11:44 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a760df316510fc56576d0934f33577a4ce64b146
      https://github.com/llvm/llvm-project/commit/a760df316510fc56576d0934f33577a4ce64b146
  Author: Mital Ashok <mital at mitalashok.co.uk>
  Date:   2024-08-08 (Thu, 08 Aug 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/lib/Sema/SemaInit.cpp
    M clang/lib/Sema/SemaOverload.cpp
    M clang/test/CXX/drs/cwg14xx.cpp
    M clang/test/CXX/drs/cwg21xx.cpp
    M clang/test/CXX/drs/cwg23xx.cpp
    M clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
    A clang/test/SemaCXX/single-element-init-list.cpp
    M clang/www/cxx_dr_status.html

  Log Message:
  -----------
  [Clang] Implement CWG2137 (list-initialization from objects of the same type) (#94355)

[CWG2137](https://cplusplus.github.io/CWG/issues/2137.html)

This was previously implemented and then reverted in Clang 18 as #77768

This also implements a workaround for
[CWG2311](https://cplusplus.github.io/CWG/issues/2311.html), similarly
to the 2024-03-01 comment for
[CWG2742](https://cplusplus.github.io/CWG/issues/2742.html).

The exact wording this tries to implement, relative to the C++26 draft:

[over.match.list]p(1.2)

> Otherwise, or if no viable initializer-list constructor is found
<ins>and the initializer list does not consist of exactly a single
element with the same cv-unqualified class type as `T`</ins>, overload
resolution is performed again, [...]

[dcl.init.list]p(3.7)

> Otherwise, if `T` is a class type, constructors are considered. The
applicable constructors are enumerated and the best one is chosen
through overload resolution. <ins>If no constructor is found and the
initializer list consists of exactly a single element with the same
cv-unqualified class type as `T`, the object is initialized from that
element (by copy-initialization for copy-list-initialization, or by
direct-initialization for direct-list-initialization). Otherwise,</ins>
if a narrowing conversion (see below) is required [...]



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list