Skip to content

Commit d52e1e8

Browse files
committed
Update sema test
1 parent 2009bb9 commit d52e1e8

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13167,9 +13167,9 @@ def err_wasm_builtin_arg_must_match_table_element_type : Error <
1316713167
def err_wasm_builtin_arg_must_be_integer_type : Error <
1316813168
"%ordinal0 argument must be an integer">;
1316913169
def err_wasm_builtin_test_fp_sig_cannot_include_reference_type
13170-
: Error<"__builtin_wasm_test_function_pointer_signature not supported for "
13171-
"function pointers with reference types in their "
13172-
"%select{return|parameter}0 type">;
13170+
: Error<"not supported for "
13171+
"function pointers with a reference type %select{return "
13172+
"value|parameter}0">;
1317313173

1317413174
// OpenACC diagnostics.
1317513175
def warn_acc_routine_unimplemented

clang/test/Sema/builtins-wasm.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,27 @@ void test_table_copy(int dst_idx, int src_idx, int nelem) {
5454
__builtin_wasm_table_copy(table, table, dst_idx, src_idx, table); // expected-error {{5th argument must be an integer}}
5555
__builtin_wasm_table_copy(table, table, dst_idx, src_idx, nelem);
5656
}
57+
58+
typedef void (*F1)(void);
59+
typedef int (*F2)(int);
60+
typedef int (*F3)(__externref_t);
61+
typedef __externref_t (*F4)(int);
62+
63+
void test_function_pointer_signature() {
64+
// Test argument count validation
65+
(void)__builtin_wasm_test_function_pointer_signature(); // expected-error {{too few arguments to function call, expected 1, have 0}}
66+
(void)__builtin_wasm_test_function_pointer_signature((F1)0, (F2)0); // expected-error {{too many arguments to function call, expected 1, have 2}}
67+
68+
// // Test argument type validation - should require function pointer
69+
(void)__builtin_wasm_test_function_pointer_signature((void*)0); // expected-error {{used type 'void *' where function pointer is required}}
70+
(void)__builtin_wasm_test_function_pointer_signature((int)0); // expected-error {{used type 'int' where function pointer is required}}
71+
(void)__builtin_wasm_test_function_pointer_signature((F3)0); // expected-error {{not supported for function pointers with a reference type parameter}}
72+
(void)__builtin_wasm_test_function_pointer_signature((F4)0); // expected-error {{not supported for function pointers with a reference type return value}}
73+
74+
// // Test valid usage
75+
int res = __builtin_wasm_test_function_pointer_signature((F1)0);
76+
res = __builtin_wasm_test_function_pointer_signature((F2)0);
77+
78+
// Test return type
79+
_Static_assert(EXPR_HAS_TYPE(__builtin_wasm_test_function_pointer_signature((F1)0), int), "");
80+
}

0 commit comments

Comments
 (0)