<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/60524>60524</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Friend function reported to be undeclared unless one of the arguments is the class type
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ShawnZhong
      </td>
    </tr>
</table>

<pre>
    In the example below, `foo` is reported to be undeclared unless one of the arguments is the class type. 

```cpp
struct S {
  friend void foo(int){};
  friend void foo(void*){};
  friend void foo(void*, void*){};
};

void test() {
  foo(0);  // use of undeclared identifier 'foo'

  foo(nullptr); // use of undeclared identifier 'foo'
  foo((S*)nullptr);  // no error

  foo(nullptr, nullptr);          // use of undeclared identifier 'foo'
  foo((S*)nullptr, nullptr);      // no error
 foo(nullptr, (S*)nullptr);      // no error
  foo((S*)nullptr, (S*)nullptr);  // no error
}
```


I think that in all the cases, `foo` should be declared (and also defined), so the program should be valid. 
https://eel.is/c++draft/class.friend#example-6 provides an example of defining friend function within the class. 

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyslE1v-ygQxj8Nvowa4fFbcvChSRSp5972hs3YZpeABTjZfvsVdtw23bZS_2oUEQczP54ZmEd4r3pDVLNiz4pjIqYwWFc_D-Jq_hqs6ZPGypf6yUAYCOhfcR41QUPaXhkegJW8s5aVHJQHR6N1gSQECw3BZCS1WjiSMBlN3oM1BLabScL105lM8DEwTrRaeA_hZaQNMH5k_PE2lnz5tuO4zPjgpjbAM7Bqv8wAdE6RkXCxSkIUhFtlAsNdXFIdWfbNwvjI8PGHiw_wZdzd8zzOgEA-MNwy3N0Jn7E8UrI9AMMTwxNMfi7UuwoqSSaoTpEDhtUcVb3fYiWZSesxuBvvD3AriOH2eUnvHrkyjQVyzrpvRRzgQ_D6-V1hn27zqc7_C_wyz68Z3wn5Ydmq44dbfnf15_EJwqDMPxAGEUAZEFovDSM8-fse9IOdtIy991pPhlthJAjtLUjqlCEZFeEBvJ0xo7O9E-d3sRehlVybcAhh9Cx7XOQT6Y3yDE8twz3DvXSiC_FvbN7N0i4Ms5tNPJSRflGSPAjzah62W5Qo068d1k2mDcoauKqY7JshrDISWWdyl-1EQnVaVkW-KypeJENNMq_ytMuowR1u05LSkvM07TqRixI7magaOWYcec4r3GKxabIiS1FUTVfkW9mlLOd0FkpvtL6cN9b1ifJ-orrkBeaJFg1pP7sjoqErzC8ZYjRLV8eYh2bqPcu5Vj74N0pQQc-2etDC9Kw4wulDsr_kl8nkdH1_Tr0Kw9RsWntmeIqKbj8Po7N_UxuPbM4jHuWc538BAAD__9P300k">