| Issue |
180851
|
| Summary |
Declaration matching fails for `inline` friend declarations
|
| Labels |
c++,
clang:frontend
|
| Assignees |
|
| Reporter |
Endilll
|
Consider the following permutation of the example from #180816, when definition of `bar` is put before definition of `Name` (https://godbolt.org/z/7x7sMGY9T):
```cpp
struct Name;
int bar(Name&) { return 0; }
struct Name {
friend inline int bar(Name);
};
int main() {
Name name;
return bar(name);
}
```
Clang, as well as other three implementations, fails to do declaration matching between definition of `bar` and its friend declaration, even though (at least in post-P1787R6 wording) `inline` specifier is not supposed to influence declaration matching at all. Instead, they are considered overloads, leading to ambiguous call in `main`.
Wording-wise, I think the critical piece is the [definition](https://eel.is/c++draft/basic.scope.scope#def:corresponding_overloads) of corresponding overloads, which is based on non-object-parameter-type-list and equivalence of requires-clauses, without any regard to `inline` specifier. Because of that, two declarations of `bar` correspond, and declare the same entity.
Then [[dcl.inline]/4](https://eel.is/c++draft/dcl.inline#4.sentence-1) makes this example ill-formed:
> If a definition of a function or variable is reachable at the point of its first declaration as inline, the program is ill-formed[.](https://eel.is/c++draft/dcl.inline#4.sentence-1)
CC @shafik
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs