Skip to content

Commit

Permalink
tests: explicitly cast incompatible function pointers
Browse files Browse the repository at this point in the history
also needed for Darwin CI
  • Loading branch information
fw-immunant committed Oct 22, 2024
1 parent 792ae54 commit ef77378
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions tests/casts/src/casts.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions tests/pointers/src/function_pointers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down

0 comments on commit ef77378

Please sign in to comment.