[PATCH] D134145: [Clang] Implement fix for DR2628

Roy Jacobson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 18 13:12:40 PDT 2022


royjacobson created this revision.
Herald added a project: All.
royjacobson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Implement suggested fix for DR2628. Coulnd't update the DR docs because there hasn't been a new DRs index, but the tests still run.

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 that should be more efficient without (hopefully) sacrificing correctness.

Closes:
https://github.com/llvm/llvm-project/issues/57646
https://github.com/llvm/llvm-project/issues/43829


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134145

Files:
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/CXX/drs/dr26xx.cpp


Index: clang/test/CXX/drs/dr26xx.cpp
===================================================================
--- /dev/null
+++ clang/test/CXX/drs/dr26xx.cpp
@@ -0,0 +1,15 @@
+// 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; // expected-note {{marked deleted here}}
+  constexpr foo() requires (A || B) = delete;
+};
+
+void f() {
+  foo fooable; // expected-error {{call to deleted}}
+}
+
+}
Index: clang/lib/Sema/SemaTemplate.cpp
===================================================================
--- clang/lib/Sema/SemaTemplate.cpp
+++ 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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134145.461095.patch
Type: text/x-patch
Size: 1093 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220918/3479155c/attachment.bin>


More information about the cfe-commits mailing list