Skip to content

Commit fa53cfa

Browse files
committed
[runtime] Fix -Wcast-function-type-mismatch warnings; NFC (1/4)
Reduction helpers in the Classic Flang runtime for different data types have different function signatures, yet they are stored in tables with generic types (e.g. void (*)())and are often compared with each other in contexts requiring explicit casts. As of Clang 19, this type of code has resulted in new compile-time warnings. This patch fixes the cases where the generic void (*)() type is not used, and explicit casts are no longer sufficient to silence the compiler.
1 parent b3f00e5 commit fa53cfa

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

runtime/flang/red_count.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,13 @@ COUNTFNLKN(count_int8, __INT8_T, 8)
8484

8585
static void (*l_count[4][__NTYPES])() = TYPELIST2LK(l_count_);
8686

87-
static void I8(g_count)(__INT_T n, __INT_T *lr, __INT_T *rr, void *lv, void *rv)
87+
static void I8(g_count)(__INT_T n, void *lr, void *rr, void *lv, void *rv, __INT_T unused)
8888
{
8989
__INT_T i;
90+
__INT_T *lr_i = (__INT_T *)lr;
91+
__INT_T *rr_i = (__INT_T *)rr;
9092
for (i = 0; i < n; i++) {
91-
lr[i] = lr[i] + rr[i];
93+
lr_i[i] = lr_i[i] + rr_i[i];
9294
}
9395
}
9496

@@ -110,8 +112,7 @@ void ENTFTN(COUNTS, counts)(char *rb, char *mb, DECL_HDR_PTRS(rs), F90_Desc *ms)
110112
z.lk_shift = GET_DIST_SHIFTS(F90_KIND_G(ms));
111113
}
112114
z.l_fn = l_count[z.lk_shift][ms->kind];
113-
z.g_fn =
114-
(void (*)(__INT_T, void *, void *, void *, void *, __INT_T))I8(g_count);
115+
z.g_fn = I8(g_count);
115116
z.zb = GET_DIST_ZED;
116117
*(__INT_T *)rb = 0;
117118
I8(__fort_red_scalar)(&z, rb, mb, (char *)GET_DIST_TRUE_LOG_ADDR,
@@ -137,8 +138,7 @@ void ENTFTN(COUNT, count)(char *rb, char *mb, char *db, DECL_HDR_PTRS(rs),
137138
z.lk_shift = GET_DIST_SHIFTS(F90_KIND_G(ms));
138139
}
139140
z.l_fn = l_count[z.lk_shift][ms->kind];
140-
z.g_fn =
141-
(void (*)(__INT_T, void *, void *, void *, void *, __INT_T))I8(g_count);
141+
z.g_fn = I8(g_count);
142142
z.zb = GET_DIST_ZED;
143143
I8(__fort_red_array)(&z, rb, mb, (char *)GET_DIST_TRUE_LOG_ADDR, db,
144144
rs, ms, (F90_Desc *)&mask_desc, ds, __COUNT);

0 commit comments

Comments
 (0)