Issue |
143929
|
Summary |
WebAssembly tables cannot be declared in non-global scope
|
Labels |
new issue
|
Assignees |
|
Reporter |
feedab1e
|
While a declaration like the following is accepted by the compiler:
```cpp
static __externref_t table[0];
```
the same declaration in a namespace is not ([link](https://gcc.godbolt.org/z/qWbcfTj6E)):
```cpp
namespace foo {
static __externref_t table1[0];
};
```
produces
```
<source>:2:26: error: WebAssembly table cannot be declared within a function
2 | static __externref_t table1[0];
| ^
1 error generated.
Compiler returned: 1
```
which is a fairly strange diagnostic considering that the declaration is not in a function.
The same issue occurs when trying to declare a table as a static member of a class or inside a function ([link](https://gcc.godbolt.org/z/WW4oP37G6)):
```cpp
struct bar {
static __externref_t table2[0];
};
void baz() {
static __externref_t table3[0];
}
```
produces
```
<source>:2:26: error: WebAssembly table cannot be declared within a function
2 | static __externref_t table2[0];
| ^
<source>:5:26: error: WebAssembly table cannot be declared within a function
5 | static __externref_t table3[0];
| ^
```
Even though the last diagnostic is right in that the declaration is in a function, I don't see a reason why this shouldn't be allowed.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs