Skip to content

Commit 5b4748e

Browse files
committed
In ExprRequirement building, treat OverloadExpr as dependent
As reported in llvm#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: llvm#66612
1 parent 917392a commit 5b4748e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

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)