| 1 |
// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -fsyntax-only -verify -triple wasm32 -Wno-unused-value -target-feature +reference-types %s |
| 2 |
// RUN: %clang_cc1 -std=c++20 -fcxx-exceptions -fexceptions -fsyntax-only -verify -triple wasm32 -Wno-unused-value -target-feature +reference-types %s |
| 3 |
|
| 4 |
// |
| 5 |
// Note: As WebAssembly references are sizeless types, we don't exhaustively |
| 6 |
// test for cases covered by sizeless-1.c and similar tests. |
| 7 |
|
| 8 |
// Using c++11 to test dynamic exception specifications (which are not |
| 9 |
// allowed in c++17). |
| 10 |
|
| 11 |
// Unlike standard sizeless types, reftype globals are supported. |
| 12 |
__externref_t r1; |
| 13 |
static __externref_t table[0]; |
| 14 |
|
| 15 |
#if (_cplusplus == 201103L) |
| 16 |
__externref_t func(__externref_t ref) throw(__externref_t) { // expected-error {{WebAssembly reference type not allowed in exception specification}} |
| 17 |
return ref; |
| 18 |
} |
| 19 |
#endif |
| 20 |
|
| 21 |
void *ret_void_ptr() { |
| 22 |
throw table; // expected-error {{cannot throw a WebAssembly reference type}} |
| 23 |
throw r1; // expected-error {{cannot throw a WebAssembly reference type}} |
| 24 |
try {} |
| 25 |
catch (__externref_t T) { // expected-error {{cannot catch a WebAssembly reference type}} |
| 26 |
(void)0; |
| 27 |
} |
| 28 |
|
| 29 |
return table; // expected-error {{cannot return a WebAssembly table}} |
| 30 |
} |