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
`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
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);
--- /dev/null
+// 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}}
+}
+
+}