- 
                Notifications
    You must be signed in to change notification settings 
- Fork 15k
[Clang] Ensure compound requirements do not contain placeholder expressions #162618
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
      
        
      
    
      
        
          +43
        
        
          −6
        
        
          
        
      
    
  
Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    | @llvm/pr-subscribers-clang Author: Corentin Jabot (cor3ntin) ChangesThe name of an overload set is not a valid id expression. Fixes #51246 Full diff: https://github.com/llvm/llvm-project/pull/162618.diff 4 Files Affected: 
 diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9a0d69c6c1b0e..2c194c50d85b6 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -455,6 +455,7 @@ Bug Fixes to C++ Support
 - Fix a crash when attempting to deduce a deduction guide from a non deducible template template parameter. (#130604)
 - Fix for clang incorrectly rejecting the default construction of a union with
   nontrivial member when another member has an initializer. (#GH81774)
+- Diagnose unresolved overload sets in non-dependent compound requirements. (#51246)
 
 Bug Fixes to AST Handling
 ^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp
index a2c69578d5087..0147ce5ba085c 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -3369,6 +3369,8 @@ ExprResult Parser::ParseRequiresExpression() {
         //         expression ';'
         SourceLocation StartLoc = Tok.getLocation();
         ExprResult Expression = ParseExpression();
+        if (Expression.isUsable())
+          Expression = Actions.CheckPlaceholderExpr(Expression.get());
         if (!Expression.isUsable()) {
           SkipUntil(tok::semi, tok::r_brace, SkipUntilFlags::StopBeforeMatch);
           break;
diff --git a/clang/test/AST/ByteCode/libcxx/deref-to-array.cpp b/clang/test/AST/ByteCode/libcxx/deref-to-array.cpp
index 2a527ab336a0d..7cfcd76b3965a 100644
--- a/clang/test/AST/ByteCode/libcxx/deref-to-array.cpp
+++ b/clang/test/AST/ByteCode/libcxx/deref-to-array.cpp
@@ -270,7 +270,7 @@ template <class _Op, class _Yp>
 void __is_derived_from_view_interface();
 template <class _Tp>
 bool enable_view = derived_from<_Tp, int> ||
-                   requires { ranges::__is_derived_from_view_interface; };
+                   requires { ranges::__is_derived_from_view_interface<_Tp, int>(); };
 template <class>
 concept range = requires { ranges::end; };
 template <class _Tp>
diff --git a/clang/test/SemaTemplate/concepts.cpp b/clang/test/SemaTemplate/concepts.cpp
index 3b7c138f83364..5f7fc63d321cf 100644
--- a/clang/test/SemaTemplate/concepts.cpp
+++ b/clang/test/SemaTemplate/concepts.cpp
@@ -1407,7 +1407,6 @@ static_assert(!std::is_constructible_v<span<4>, array<int, 3>>);
 
 }
 
-
 namespace GH162125 {
 template<typename, int size>
 concept true_int = (size, true);
@@ -1444,3 +1443,23 @@ struct s {
 
 void(*test)(int) = &s<bool>::f<int>;
 }
+namespace GH51246 {
+void f(); // expected-note {{possible target for call}}
+void f(int); // expected-note {{possible target for call}}
+void g();
+static_assert(requires { f; }); // expected-error {{reference to overloaded function could not be resolved}}
+static_assert(requires { g; });
+struct S {
+    void mf() {
+        static_assert(requires { mf(); });
+        static_assert(requires { mf; });    // expected-error {{reference to non-static member function must be called}}
+        static_assert(requires { S::mf; }); // expected-error {{reference to non-static member function must be called}}
+    }
+    void mf2(int); // expected-note 2{{possible target for call}}
+    void mf2() { // expected-note 2{{possible target for call}}
+        static_assert(requires { mf2; });    // expected-error {{reference to non-static member function must be called}}
+        static_assert(requires { S::mf2; }); // expected-error {{reference to non-static member function must be called}}
+    }
+};
+
+} // namespace GH51246
 | 
placeholder expressions The name of an overloasd set is not a valid id expression. Fixes llvm#51246 Fixes llvm#97753
fd65f0c    to
    5b3e3d5      
    Compare
  
    
            
                  zyn0217
  
            
            approved these changes
            
                
                  Oct 9, 2025 
                
            
            
          
          
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one nit
            
                  erichkeane
  
            
            approved these changes
            
                
                  Oct 9, 2025 
                
            
            
          
          
    
  DharuniRAcharya 
      pushed a commit
        to DharuniRAcharya/llvm-project
      that referenced
      this pull request
    
      Oct 13, 2025 
    
    
      
  
    
      
    
  
…ssions (llvm#162618) The name of an overload set is not a valid id expression. Fixes llvm#51246
    
  akadutta 
      pushed a commit
        to akadutta/llvm-project
      that referenced
      this pull request
    
      Oct 14, 2025 
    
    
      
  
    
      
    
  
…ssions (llvm#162618) The name of an overload set is not a valid id expression. Fixes llvm#51246
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      Labels
      
    clang:bytecode
  Issues for the clang bytecode constexpr interpreter 
  
    clang:frontend
  Language frontend issues, e.g. anything involving "Sema" 
  
    clang
  Clang issues not falling into any other category 
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
The name of an overload set is not a valid id expression.
Fixes #51246