Skip to content

Commit 11bb5e5

Browse files
authored
In ExprRequirement building, treat OverloadExpr as dependent (#66683)
As reported in #66612, we aren't correctly treating the placeholder expression type correctly, so we ended up trying to get a reference version of it, and this resulted in an assertion, since the placeholder type cannot have a reference added. Fixes: #66612
1 parent ddf7cc2 commit 11bb5e5

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,9 @@ Bug Fixes to C++ Support
305305
that contains a `return`.
306306
(`#48527 <https://github.com/llvm/llvm-project/issues/48527>`_)
307307

308+
- Clang now no longer asserts when an UnresolvedLookupExpr is used as an
309+
expression requirement. (`#66612 https://github.com/llvm/llvm-project/issues/66612`)
310+
308311
Bug Fixes to AST Handling
309312
^^^^^^^^^^^^^^^^^^^^^^^^^
310313
- Fixed an import failure of recursive friend class template.

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9063,7 +9063,8 @@ Sema::BuildExprRequirement(
90639063
concepts::ExprRequirement::ReturnTypeRequirement ReturnTypeRequirement) {
90649064
auto Status = concepts::ExprRequirement::SS_Satisfied;
90659065
ConceptSpecializationExpr *SubstitutedConstraintExpr = nullptr;
9066-
if (E->isInstantiationDependent() || ReturnTypeRequirement.isDependent())
9066+
if (E->isInstantiationDependent() || E->getType()->isPlaceholderType() ||
9067+
ReturnTypeRequirement.isDependent())
90679068
Status = concepts::ExprRequirement::SS_Dependent;
90689069
else if (NoexceptLoc.isValid() && canThrow(E) == CanThrowResult::CT_Can)
90699070
Status = concepts::ExprRequirement::SS_NoexceptNotMet;

clang/test/SemaTemplate/concepts.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,3 +1031,20 @@ void test() {
10311031
fff(42UL); // expected-error {{no matching function}}
10321032
}
10331033
}
1034+
1035+
namespace GH66612 {
1036+
template<typename C>
1037+
auto end(C c) ->int;
1038+
1039+
template <typename T>
1040+
concept Iterator = true;
1041+
1042+
template <typename CT>
1043+
concept Container = requires(CT b) {
1044+
{ end } -> Iterator; // #66612GH_END
1045+
};
1046+
1047+
static_assert(Container<int>);// expected-error{{static assertion failed}}
1048+
// expected-note@-1{{because 'int' does not satisfy 'Container'}}
1049+
// expected-note@#66612GH_END{{because 'end' would be invalid: reference to overloaded function could not be resolved; did you mean to call it?}}
1050+
}

0 commit comments

Comments
 (0)