Skip to content

Commit 6cc5275

Browse files
committed
[runtime] Fix -Wcast-qual warnings
Since upgrading to Clang/LLVM 17, the Classic Flang build now fails with a large number of errors with this message: error: cast from 'const char *' to 'char *' drops const qualifier [-Werror,-Wcast-qual] This patch fixes all such warnings in runtime/.
1 parent 167af1d commit 6cc5275

File tree

14 files changed

+56
-58
lines changed

14 files changed

+56
-58
lines changed

runtime/flang/eoshift.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
static void I8(eoshift_scalar)(char *rb, /* result base */
1616
char *ab, /* array base */
1717
__INT_T shift_amt, /* shift amount */
18-
char *bb, /* boundary base */
18+
const char *bb, /* boundary base */
1919
__INT_T shift_dim, /* shift dimension */
2020
F90_Desc *rs, /* result descriptor */
2121
F90_Desc *as, /* array descriptor */
@@ -237,7 +237,7 @@ static void I8(eoshift_scalar)(char *rb, /* result base */
237237
static void I8(eoshift_loop)(char *rb, /* result base */
238238
char *ab, /* array base */
239239
__INT_T *sb, /* shift base */
240-
char *bb, /* boundary base */
240+
const char *bb, /* boundary base */
241241
__INT_T shift_dim, /* dimension to shift */
242242
F90_Desc *rs, /* result descriptor */
243243
F90_Desc *as, /* array descriptor */
@@ -342,7 +342,7 @@ void ENTFTN(EOSHIFTSZ, eoshiftsz)(char *rb, /* result base */
342342
F90_Desc *ss, /* shift descriptor */
343343
F90_Desc *ds) /* dim descriptor */
344344
{
345-
char *bb;
345+
const char *bb;
346346
DECL_HDR_VARS(ac);
347347
DECL_HDR_VARS(rc);
348348
DECL_DIM_PTRS(asd);
@@ -351,8 +351,7 @@ void ENTFTN(EOSHIFTSZ, eoshiftsz)(char *rb, /* result base */
351351

352352
shift = *sb;
353353
dim = *db;
354-
/* FIXME: bb is passed to many non-const parameters; just cast it for now. */
355-
bb = (F90_KIND_G(rs) == __STR) ? (char *)" " : (char *)GET_DIST_ZED;
354+
bb = (F90_KIND_G(rs) == __STR) ? " " : (const char *)GET_DIST_ZED;
356355

357356
#if defined(DEBUG)
358357
if (__fort_test & DEBUG_EOSH) {
@@ -597,12 +596,11 @@ void ENTFTN(EOSHIFTZ, eoshiftz)(char *rb, /* result base */
597596
DECL_HDR_PTRS(bs);
598597
DECL_HDR_VARS(ac);
599598
DECL_HDR_VARS(rc);
600-
char *bb;
599+
const char *bb;
601600
__INT_T dim;
602601

603602
dim = *db;
604-
/* FIXME: bb is passed to many non-const parameters; just cast it for now. */
605-
bb = (F90_KIND_G(rs) == __STR) ? (char *)" " : (char *)GET_DIST_ZED;
603+
bb = (F90_KIND_G(rs) == __STR) ? " " : (const char *)GET_DIST_ZED;
606604
bs = (F90_Desc *)&F90_KIND_G(rs);
607605

608606
#if defined(DEBUG)

runtime/flang/fill.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "fioMacros.h"
1010

1111
#include "fort_vars.h"
12-
extern void (*__fort_scalar_copy[__NTYPES])(void *rp, void *sp, int size);
12+
extern void (*__fort_scalar_copy[__NTYPES])(void *rp, const void *sp, int size);
1313

1414
static void I8(fills_loop)(char *ab, F90_Desc *as, void *fb, __INT_T off0,
1515
__INT_T dim)

runtime/flang/map.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
static int
1919
compar_tids(const void *a, const void *b)
2020
{
21-
return *(int *)a - *(int *)b;
21+
return *(const int *)a - *(const int *)b;
2222
}
2323

2424
/* Verify the logical to physical processor map */

runtime/flang/mget.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#define QTREE
1616

1717
#include "fort_vars.h"
18-
extern void (*__fort_scalar_copy[__NTYPES])(void *rp, void *sp, int size);
18+
extern void (*__fort_scalar_copy[__NTYPES])(void *rp, const void *sp, int size);
1919

2020
static int _1 = 1;
2121

runtime/flang/mmul.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
typedef void (*mmul_fn)(void *, int, void *, int, int, void *, int, int);
2020

2121
extern void (*I8(__fort_g_sum)[__NTYPES])();
22-
extern void (*__fort_scalar_copy[__NTYPES])(void *rp, void *sp, int len);
22+
extern void (*__fort_scalar_copy[__NTYPES])(void *rp, const void *sp, int len);
2323

2424
void ENTFTN(QOPY_IN, qopy_in)(char **dptr, __POINT_T *doff, char *dbase,
2525
F90_Desc *dd, char *ab, F90_Desc *ad,

runtime/flang/olap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "fioMacros.h"
1414

1515
#include "fort_vars.h"
16-
extern void (*__fort_scalar_copy[__NTYPES])(void *rp, void *sp, int size);
16+
extern void (*__fort_scalar_copy[__NTYPES])(void *rp, const void *sp, int size);
1717

1818
/* overlap shift communication schedule */
1919

runtime/flang/pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "stdioInterf.h"
1313
#include "fioMacros.h"
1414

15-
extern void (*__fort_scalar_copy[__NTYPES])(void *rp, void *sp, int len);
15+
extern void (*__fort_scalar_copy[__NTYPES])(void *rp, const void *sp, int len);
1616

1717
static int I8(next_index)(__INT_T *index, F90_Desc *s)
1818
{

runtime/flang/red.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "fioMacros.h"
1616
#include "red.h"
1717

18-
extern void (*__fort_scalar_copy[__NTYPES])(void *rp, void *sp, int len);
18+
extern void (*__fort_scalar_copy[__NTYPES])(void *rp, const void *sp, int len);
1919

2020
void ENTFTN(QOPY_IN, qopy_in)(char **dptr, __POINT_T *doff, char *dbase,
2121
F90_Desc *dd, char *ab, F90_Desc *ad,

runtime/flang/reshape.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include "stdioInterf.h"
1111
#include "fioMacros.h"
1212

13-
extern void (*__fort_scalar_copy[__NTYPES])(void *rp, void *sp, int len);
13+
extern void (*__fort_scalar_copy[__NTYPES])(void *rp, const void *sp, int len);
1414

1515
/* advance index n elements and return the remaining extent in the
1616
first dimension from that point. When the end of the array is

runtime/flang/scal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "fioMacros.h"
1414

1515
#include "fort_vars.h"
16-
extern void (*__fort_scalar_copy[__NTYPES])(void *rp, void *sp, int size);
16+
extern void (*__fort_scalar_copy[__NTYPES])(void *rp, const void *sp, int size);
1717

1818
/* all processors get the value of the selected array element */
1919

0 commit comments

Comments
 (0)