From 9b639abf115d83aa497ddb127eed3e8b600f9751 Mon Sep 17 00:00:00 2001 From: fw Date: Tue, 22 Oct 2024 11:46:08 -0400 Subject: [PATCH] tests: explicitly cast incompatible function pointers also needed for Darwin CI --- tests/casts/src/casts.c | 4 ++-- tests/pointers/src/function_pointers.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/casts/src/casts.c b/tests/casts/src/casts.c index f881e46314..98d3ab0cea 100644 --- a/tests/casts/src/casts.c +++ b/tests/casts/src/casts.c @@ -7,8 +7,8 @@ void cast_stuff(void) { const int *cintp = 0; char *x1 = (char*) intp; int *x2 = (int*) intp; - void(*f)(unsigned, int*) = cast_stuff; - void(*g)(unsigned, int*) = &cast_stuff; + void(*f)(unsigned, int*) = (void(*)(unsigned, int*))cast_stuff; + void(*g)(unsigned, int*) = (void(*)(unsigned, int*))&cast_stuff; //(union intfloat)1; int *x3 = (int*)inta; int *x4 = (int*)0; diff --git a/tests/pointers/src/function_pointers.c b/tests/pointers/src/function_pointers.c index a9810819ec..b54ae72a1a 100644 --- a/tests/pointers/src/function_pointers.c +++ b/tests/pointers/src/function_pointers.c @@ -75,16 +75,16 @@ void entry3(const unsigned sz, int buffer[const]) // Test valid casts between function pointers // with additional parameters - char_int_to_int_fp p9 = &intval, p10 = p7; + char_int_to_int_fp p9 = (char_int_to_int_fp)&intval, p10 = (char_int_to_int_fp)p7; buffer[i++] = p9('D', 42); buffer[i++] = p10('E', 1337); // Test K&R style function pointers - knr *p11 = 1; - knr *p12 = intval; - knr *p13 = &intval; + knr *p11 = (knr *)1; + knr *p12 = (knr *)intval; + knr *p13 = (knr *)&intval; struct pointer_st s; - s.fn = intval; + s.fn = (int (*)())intval; buffer[i++] = p12('a'); buffer[i++] = p13('a'); buffer[i++] = (*(s).fn)(('a'));