Issue |
137282
|
Summary |
[clang enhancement] improve -Wreturn-type-c-linkage warning message
|
Labels |
clang
|
Assignees |
|
Reporter |
illusory0x0
|
When I write the code below, clang report warning, but `struct Foo` is complete type. the Foo<int> doesn't instantiate template. We can instantiate this type in C++ linkage scope, then Most of complier can complies successfully.
### Expected Behavior
add more usefull infomation help user to solve.
```
try to instantiate template in C++ linkage, if this excectly not incomplete type.
```
### Actual Behavior
```
<source>:14:14: warning: 'foo' has C-linkage specified, but returns incomplete type 'Foo<int>' which could be incompatible with C [-Wreturn-type-c-linkage]
```
```C++
template<typename T>
struct Foo {
T* ptr;
};
void force_instantiate_template() {
// Foo<int> x;
// If uncooment the line above, clang woundn't report warning.
// and MSVC will complie successfully.
}
extern "C" {
Foo<int> foo() {
return { .ptr = nullptr } ;
}
void bar(Foo<int>) {
}
}
```
[godbolt](https://godbolt.org/z/e54Gb61Kx)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs