diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -4769,7 +4769,8 @@ return DAR_FailedAlreadyDiagnosed; } - if (const auto *AT = Type.getType()->getAs()) { + if (const auto *AT = + Type.getType().getNonReferenceType()->getAs()) { if (AT->isConstrained() && !IgnoreConstraints) { auto ConstraintsResult = CheckDeducedPlaceholderConstraints(*this, *AT, diff --git a/clang/test/SemaTemplate/concepts.cpp b/clang/test/SemaTemplate/concepts.cpp --- a/clang/test/SemaTemplate/concepts.cpp +++ b/clang/test/SemaTemplate/concepts.cpp @@ -171,7 +171,7 @@ } namespace PR49188 { - template concept C = false; // expected-note 6 {{because 'false' evaluated to false}} + template concept C = false; // expected-note 7 {{because 'false' evaluated to false}} C auto f1() { // expected-error {{deduced type 'void' does not satisfy 'C'}} return void(); @@ -189,7 +189,7 @@ } C decltype(auto) f6() { // expected-error {{deduced type 'void' does not satisfy 'C'}} } - C auto& f7() { // expected-error {{cannot form a reference to 'void'}} + C auto& f7() { // expected-error {{deduced type 'void' does not satisfy 'C'}} return void(); } C auto& f8() { @@ -222,3 +222,26 @@ }; void (*f2)() = B::f; // expected-error {{address of overloaded function 'f' does not match required type}} } + +namespace PR54443 { + +template +struct is_same { static constexpr bool value = false; }; + +template +struct is_same { static constexpr bool value = true; }; + +template +concept same_as = is_same::value; // expected-note-re 4 {{because {{.*}} evaluated to false}} + +int const &f(); + +same_as auto i1 = f(); // expected-error {{deduced type 'int' does not satisfy 'same_as'}} +same_as auto &i2 = f(); +same_as auto &&i3 = f(); // expected-error {{deduced type 'const int &' does not satisfy 'same_as'}} + +same_as auto i4 = f(); // expected-error {{deduced type 'int' does not satisfy 'same_as'}} +same_as auto &i5 = f(); // expected-error {{deduced type 'const int' does not satisfy 'same_as'}} +same_as auto &&i6 = f(); + +}