diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -151,6 +151,10 @@ `Issue 57369 `_ `Issue 57643 `_ `Issue 57793 `_ +- Respect constructor constraints during class template argument deduction (CTAD). + This is the suggested resolution to CWG DR2628. + `Issue 57646 `_ + `Issue 43829 `_ Improvements to Clang's diagnostics diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -2445,6 +2445,8 @@ TInfo->getType(), TInfo, LocEnd, Ctor); Guide->setImplicit(); Guide->setParams(Params); + if (Ctor && Ctor->getTrailingRequiresClause()) + Guide->setTrailingRequiresClause(Ctor->getTrailingRequiresClause()); for (auto *Param : Params) Param->setDeclContext(Guide); diff --git a/clang/test/CXX/drs/dr26xx.cpp b/clang/test/CXX/drs/dr26xx.cpp new file mode 100644 --- /dev/null +++ b/clang/test/CXX/drs/dr26xx.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s -verify + +namespace dr2628 { // dr2628: yes + +template +struct foo { + constexpr foo() requires (!A && !B) = delete; // #DR2628_CTOR + constexpr foo() requires (A || B) = delete; +}; + +void f() { + foo fooable; // expected-error {{call to deleted}} + // expected-note@#DR2628_CTOR {{marked deleted here}} +} + +}