Skip to content
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

release/19.x: [Clang] Remove the special-casing for RequiresExprBodyDecl in BuildResolvedCallExpr() after fd87d765c0 (#111277) #111324

Merged
merged 1 commit into from
Oct 11, 2024

Conversation

llvmbot
Copy link
Collaborator

@llvmbot llvmbot commented Oct 7, 2024

Backport 8c15470

Requested by: @zyn0217

@llvmbot llvmbot added this to the LLVM 19.X Release milestone Oct 7, 2024
@llvmbot
Copy link
Collaborator Author

llvmbot commented Oct 7, 2024

@mizvekov What do you think about merging this PR to the release branch?

@llvmbot llvmbot requested a review from mizvekov October 7, 2024 01:45
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Oct 7, 2024
@llvmbot
Copy link
Collaborator Author

llvmbot commented Oct 7, 2024

@llvm/pr-subscribers-clang

Author: None (llvmbot)

Changes

Backport 8c15470

Requested by: @zyn0217


Full diff: https://github.com/llvm/llvm-project/pull/111324.diff

4 Files Affected:

  • (modified) clang/lib/Sema/SemaExpr.cpp (+1-2)
  • (modified) clang/lib/Sema/TreeTransform.h (+1-1)
  • (removed) clang/test/SemaCXX/PR84020.cpp (-23)
  • (modified) clang/test/SemaTemplate/instantiate-requires-expr.cpp (+31)
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index f56ca398cda81c..687b1be9459219 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -6922,8 +6922,7 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
   }
 
   if (CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
-    if (!isa<RequiresExprBodyDecl>(CurContext) &&
-        Method->isImplicitObjectMemberFunction())
+    if (Method->isImplicitObjectMemberFunction())
       return ExprError(Diag(LParenLoc, diag::err_member_call_without_object)
                        << Fn->getSourceRange() << 0);
 
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 51e6a4845bf6fd..0ae393524fe03a 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -13608,7 +13608,7 @@ bool TreeTransform<Derived>::TransformOverloadExprDecls(OverloadExpr *Old,
     }
 
     AllEmptyPacks &= Decls.empty();
-  };
+  }
 
   // C++ [temp.res]/8.4.2:
   //   The program is ill-formed, no diagnostic required, if [...] lookup for
diff --git a/clang/test/SemaCXX/PR84020.cpp b/clang/test/SemaCXX/PR84020.cpp
deleted file mode 100644
index 8ea5dcc4527ae7..00000000000000
--- a/clang/test/SemaCXX/PR84020.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-// RUN: %clang_cc1 -std=c++20 -verify %s
-// RUN: %clang_cc1 -std=c++23 -verify %s
-// expected-no-diagnostics
-
-struct B {
-    template <typename S>
-    void foo();
-
-    void bar();
-};
-
-template <typename T, typename S>
-struct A : T {
-    auto foo() {
-        static_assert(requires { T::template foo<S>(); });
-        static_assert(requires { T::bar(); });
-    }
-};
-
-int main() {
-    A<B, double> a;
-    a.foo();
-}
diff --git a/clang/test/SemaTemplate/instantiate-requires-expr.cpp b/clang/test/SemaTemplate/instantiate-requires-expr.cpp
index 20a19d731ae169..a1f5456156a06f 100644
--- a/clang/test/SemaTemplate/instantiate-requires-expr.cpp
+++ b/clang/test/SemaTemplate/instantiate-requires-expr.cpp
@@ -237,3 +237,34 @@ constexpr bool e_v = true;
 static_assert(e_v<bool>);
 
 } // namespace GH73885
+
+namespace GH84020 {
+
+struct B {
+  template <typename S> void foo();
+  void bar();
+};
+
+template <typename T, typename S> struct A : T {
+  void foo() {
+    static_assert(requires { T::template foo<S>(); });
+    static_assert(requires { T::bar(); });
+  }
+};
+
+template class A<B, double>;
+
+} // namespace GH84020
+
+namespace GH110785 {
+
+struct Foo {
+  static void f(auto) requires(false) {}
+  void f(int) {}
+
+  static_assert([](auto v) {
+    return requires { f(v); };
+  } (0) == false);
+};
+
+} // namespace GH110785

…solvedCallExpr() after fd87d76 (llvm#111277)

The special-casing for RequiresExprBodyDecl caused a regression, as
reported in llvm#110785.

The original fix for llvm#84020 has been superseded by fd87d76, which
establishes a `DependentScopeDeclRefExpr` instead of a
`CXXDependentScopeMemberExpr` for the case in issue. So the spurious
diagnostic in llvm#84020 would no longer occur.

This also merges the test for llvm#84020 together with that for llvm#110785 into
clang/test/SemaTemplate/instantiate-requires-expr.cpp.

No release note because I think this merits a backport.

Fixes llvm#110785

(cherry picked from commit 8c15470)
@tru tru merged commit f3f4952 into llvm:release/19.x Oct 11, 2024
8 of 9 checks passed
Copy link

@zyn0217 (or anyone else). If you would like to add a note about this fix in the release notes (completely optional). Please reply to this comment with a one or two sentence description of the fix. When you are done, please add the release:note label to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
Development

Successfully merging this pull request may close these issues.

4 participants