Author: Roy Jacobson Date: 2022-09-20T00:07:41+03:00 New Revision: 368b6832de33b366d4eb155f940e7476daace6a8
URL: https://github.com/llvm/llvm-project/commit/368b6832de33b366d4eb155f940e7476daace6a8 DIFF: https://github.com/llvm/llvm-project/commit/368b6832de33b366d4eb155f940e7476daace6a8.diff LOG: [Clang] Implement fix for DR2628 Implement suggested fix for [[ https://cplusplus.github.io/CWG/issues/2628.html | DR2628. ]] Couldn't update the DR docs because there hasn't been a DR index since it was filed, but the tests still run in CI. Note: I only transfer the constructor constraints, not the struct constraints. I think that's OK because the struct constraints are the same for all constructors so they don't affect the overload resolution, and if they deduce to something that doesn't pass the constraints we catch it anyway. So (hopefully) that should be more efficient without sacrificing correctness. Closes: https://github.com/llvm/llvm-project/issues/57646 https://github.com/llvm/llvm-project/issues/43829 Reviewed By: erichkeane Differential Revision: https://reviews.llvm.org/D134145 Added: clang/test/CXX/drs/dr26xx.cpp Modified: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaTemplate.cpp Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 2546142d2b3d7..96b0c7e363052 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -151,6 +151,10 @@ Bug Fixes `Issue 57369 <https://github.com/llvm/llvm-project/issues/57369>`_ `Issue 57643 <https://github.com/llvm/llvm-project/issues/57643>`_ `Issue 57793 <https://github.com/llvm/llvm-project/issues/57793>`_ +- Respect constructor constraints during class template argument deduction (CTAD). + This is the suggested resolution to CWG DR2628. + `Issue 57646 <https://github.com/llvm/llvm-project/issues/57646>`_ + `Issue 43829 <https://github.com/llvm/llvm-project/issues/43829>`_ Improvements to Clang's diagnostics diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index e0f913e395771..2ab59e7a37c0d 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -2445,6 +2445,8 @@ struct ConvertConstructorToDeductionGuideTransform { 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 index 0000000000000..1178cefa5bcdf --- /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 <bool A = false, bool B = false> +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}} +} + +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits