Skip to content

Commit a763b1e

Browse files
committed
Update sema test
1 parent 44ac5de commit a763b1e

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
@@ -12998,9 +12998,9 @@ def err_wasm_builtin_arg_must_match_table_element_type : Error <
1299812998
def err_wasm_builtin_arg_must_be_integer_type : Error <
1299912999
"%ordinal0 argument must be an integer">;
1300013000
def err_wasm_builtin_test_fp_sig_cannot_include_reference_type
13001-
: Error<"__builtin_wasm_test_function_pointer_signature not supported for "
13002-
"function pointers with reference types in their "
13003-
"%select{return|parameter}0 type">;
13001+
: Error<"not supported for "
13002+
"function pointers with a reference type %select{return "
13003+
"value|parameter}0">;
1300413004

1300513005
// OpenACC diagnostics.
1300613006
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
@@ -50,3 +50,27 @@ void test_table_copy(int dst_idx, int src_idx, int nelem) {
5050
__builtin_wasm_table_copy(table, table, dst_idx, src_idx, table); // expected-error {{5th argument must be an integer}}
5151
__builtin_wasm_table_copy(table, table, dst_idx, src_idx, nelem);
5252
}
53+
54+
typedef void (*F1)(void);
55+
typedef int (*F2)(int);
56+
typedef int (*F3)(__externref_t);
57+
typedef __externref_t (*F4)(int);
58+
59+
void test_function_pointer_signature() {
60+
// Test argument count validation
61+
(void)__builtin_wasm_test_function_pointer_signature(); // expected-error {{too few arguments to function call, expected 1, have 0}}
62+
(void)__builtin_wasm_test_function_pointer_signature((F1)0, (F2)0); // expected-error {{too many arguments to function call, expected 1, have 2}}
63+
64+
// // Test argument type validation - should require function pointer
65+
(void)__builtin_wasm_test_function_pointer_signature((void*)0); // expected-error {{used type 'void *' where function pointer is required}}
66+
(void)__builtin_wasm_test_function_pointer_signature((int)0); // expected-error {{used type 'int' where function pointer is required}}
67+
(void)__builtin_wasm_test_function_pointer_signature((F3)0); // expected-error {{not supported for function pointers with a reference type parameter}}
68+
(void)__builtin_wasm_test_function_pointer_signature((F4)0); // expected-error {{not supported for function pointers with a reference type return value}}
69+
70+
// // Test valid usage
71+
int res = __builtin_wasm_test_function_pointer_signature((F1)0);
72+
res = __builtin_wasm_test_function_pointer_signature((F2)0);
73+
74+
// Test return type
75+
_Static_assert(EXPR_HAS_TYPE(__builtin_wasm_test_function_pointer_signature((F1)0), int), "");
76+
}

0 commit comments

Comments
 (0)