<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64528>64528</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Function declaration at block scope is bound in surrounding scope
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mcmlevi
</td>
</tr>
</table>
<pre>
So recently I ran into a bug on [MSVC](https://developercommunity.visualstudio.com/t/Forward-declarations-inside-of-a-functio/10432628) , during testing and research into this issue me and some other folks ran into a issue that's somewhat similar.
If you take the following code sample this shouldn't compile as specified in the following draft[https://eel.is/c++draft/dcl.dcl#dcl.meaning.general-3.5]
> If the declaration inhabits a block scope S and declares a function ([[dcl.fct]](https://eel.is/c++draft/dcl.dcl#dcl.fct)) or uses the extern specifier, the declaration shall not be attached to a named module ([[module.unit]](https://eel.is/c++draft/module.unit)); its target scope is the innermost enclosing namespace scope, but the name is bound in S[.](https://eel.is/c++draft/dcl.dcl#dcl.meaning.general-3.5.sentence-1)
```cpp
namespace Foo
{
void SomeOuterFunc()
{
void someFunc(int);
someFunc(0);
}
}
void Foo::someFunc(int)
{
}
int main() {
Foo::SomeOuterFunc();
}
```
So with that, this shouldn't compile on Clang and should produce an error similar to GCC
```
<source>:10:6: warning: 'void Foo::someFunc(int)' has not been declared within 'Foo'
10 | void Foo::someFunc(int)
| ^~~
<source>:5:22: note: only here as a 'friend'
5 | void someFunc(int);
|
````
or MSVC
```
1>main.cpp(17,11): error C2039: 'someFunc': is not a member of 'Foo'
1>main.cpp(8): message : see declaration of 'Foo'
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVk2TqygU_TVkcyuWQoxxkUU-2qleTM0iVbNHuEamEVKAnenN--1TqOmY7ky9N5NKKcrhcjj3cpB7r84GcUvyPcmPC96H1rptJzqN72pRW_mxPVlwKNAE_QGv4LgBZYIFDnV_BmuA5P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