[llvm] In ExprRequirement building, treat OverloadExpr as dependent (PR #66683)

Erich Keane via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 19 07:14:34 PDT 2023


https://github.com/erichkeane updated https://github.com/llvm/llvm-project/pull/66683

>From 5b4748e3ae06a5b90ecb2c84b7df989a94733175 Mon Sep 17 00:00:00 2001
From: erichkeane <ekeane at nvidia.com>
Date: Mon, 18 Sep 2023 11:38:12 -0700
Subject: [PATCH 1/3] In ExprRequirement building, treat OverloadExpr as
 dependent

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
---
 clang/lib/Sema/SemaExprCXX.cpp       |  3 ++-
 clang/test/SemaTemplate/concepts.cpp | 17 +++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

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?}}
+}

>From 8956c6575db7a7a9cbfd3750ea688f78b3fb4d53 Mon Sep 17 00:00:00 2001
From: erichkeane <ekeane at nvidia.com>
Date: Mon, 18 Sep 2023 12:51:36 -0700
Subject: [PATCH 2/3] Add Release Note

---
 clang/docs/ReleaseNotes.rst | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 500f9c9a0cda741..3ff5882b081d8b4 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -291,6 +291,9 @@ Bug Fixes to C++ Support
   pointers on win32.
   (`#62594 <https://github.com/llvm/llvm-project/issues/62594>`_)
 
+- 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.

>From 71cf811d6bb793ce8fa076f3af63523ebf1722e8 Mon Sep 17 00:00:00 2001
From: erichkeane <ekeane at nvidia.com>
Date: Tue, 19 Sep 2023 07:14:18 -0700
Subject: [PATCH 3/3] Fix release notes

---
 clang/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 01f97ffd857b33c..ba91f9481fe988a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -304,7 +304,7 @@ Bug Fixes to C++ Support
 - Fix crash for a lambda attribute with a statement expression
   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`)
 



More information about the llvm-commits mailing list