Skip to content

In ExprRequirement building, treat OverloadExpr as dependent #66683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ Bug Fixes to C++ Support
that contains a `return`.
(`#48527 <https://github.com/llvm/llvm-project/issues/48527>`_)

- Clang now no longer asserts when an UnresolvedLookupExpr is used as an
expression requirement. (`#66612 https://github.com/llvm/llvm-project/issues/66612`)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed an import failure of recursive friend class template.
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Sema/SemaExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9063,7 +9063,8 @@ Sema::BuildExprRequirement(
concepts::ExprRequirement::ReturnTypeRequirement ReturnTypeRequirement) {
auto Status = concepts::ExprRequirement::SS_Satisfied;
ConceptSpecializationExpr *SubstitutedConstraintExpr = nullptr;
if (E->isInstantiationDependent() || ReturnTypeRequirement.isDependent())
if (E->isInstantiationDependent() || E->getType()->isPlaceholderType() ||
ReturnTypeRequirement.isDependent())
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense in my head, as what is currently an unresolved overload expr(or other overload expr) could potentially become legal after instantiation I think? So this should result in this being instantiated later/checked for correctness then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been trying to think about whether checking UnresolvedLookupExpr would make more sense but
I think what you have works in all cases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was concerned about other expression types as well, like OverloadExpr or placeholders that got put in elsewise, so I was hoping this was sufficiently generic here.

Status = concepts::ExprRequirement::SS_Dependent;
else if (NoexceptLoc.isValid() && canThrow(E) == CanThrowResult::CT_Can)
Status = concepts::ExprRequirement::SS_NoexceptNotMet;
Expand Down
17 changes: 17 additions & 0 deletions clang/test/SemaTemplate/concepts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1031,3 +1031,20 @@ void test() {
fff(42UL); // expected-error {{no matching function}}
}
}

namespace GH66612 {
template<typename C>
auto end(C c) ->int;

template <typename T>
concept Iterator = true;

template <typename CT>
concept Container = requires(CT b) {
{ end } -> Iterator; // #66612GH_END
};

static_assert(Container<int>);// expected-error{{static assertion failed}}
// expected-note@-1{{because 'int' does not satisfy 'Container'}}
// expected-note@#66612GH_END{{because 'end' would be invalid: reference to overloaded function could not be resolved; did you mean to call it?}}
}