Skip to content

Commit

Permalink
[Clang] constraints partial ordering should work with deduction guide
Browse files Browse the repository at this point in the history
D128750 incorrectly skips constraints partial ordering for deduction guide.
This patch reverts that part.

Fixes #58456.
  • Loading branch information
Yuanfang Chen committed Oct 19, 2022
1 parent 6912ed7 commit 13d6a57
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
3 changes: 1 addition & 2 deletions clang/lib/Sema/SemaTemplateDeduction.cpp
Expand Up @@ -5243,8 +5243,7 @@ FunctionTemplateDecl *Sema::getMoreSpecializedTemplate(
}
}

if (!Context.getLangOpts().CPlusPlus20 || isa<CXXDeductionGuideDecl>(FD1) ||
isa<CXXDeductionGuideDecl>(FD2))
if (!Context.getLangOpts().CPlusPlus20)
return nullptr;

// Match GCC on not implementing [temp.func.order]p6.2.1.
Expand Down
20 changes: 20 additions & 0 deletions clang/test/SemaTemplate/deduction-guide-partial-ordering.cpp
@@ -0,0 +1,20 @@
// RUN: %clang_cc1 -std=c++20 -verify %s
// expected-no-diagnostics

namespace pr58456 {
template<typename>
struct s {
constexpr s(auto) {
}
};

template<typename T>
s(T) -> s<int>;

template<typename T> requires true
s(T) -> s<int>;

void f() {
auto const y = s(0);
}
}

0 comments on commit 13d6a57

Please sign in to comment.