[clang] In ExprRequirement building, treat OverloadExpr as dependent (PR #66683)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 18 11:47:13 PDT 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
<details>
<summary>Changes</summary>
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
---
Full diff: https://github.com/llvm/llvm-project/pull/66683.diff
2 Files Affected:
- (modified) clang/lib/Sema/SemaExprCXX.cpp (+2-1)
- (modified) clang/test/SemaTemplate/concepts.cpp (+17)
``````````diff
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index bb4ef065d5c72aa..77289595972e3cf 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -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())
Status = concepts::ExprRequirement::SS_Dependent;
else if (NoexceptLoc.isValid() && canThrow(E) == CanThrowResult::CT_Can)
Status = concepts::ExprRequirement::SS_NoexceptNotMet;
diff --git a/clang/test/SemaTemplate/concepts.cpp b/clang/test/SemaTemplate/concepts.cpp
index 891b45aa5789296..68050e0f09e248a 100644
--- a/clang/test/SemaTemplate/concepts.cpp
+++ b/clang/test/SemaTemplate/concepts.cpp
@@ -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 at -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?}}
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/66683
More information about the cfe-commits
mailing list