Skip to content

Commit 20ea7be

Browse files
authored
Merge branch 'master' into macos
2 parents eaf5c70 + ac60021 commit 20ea7be

File tree

207 files changed

+2697
-847
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

207 files changed

+2697
-847
lines changed

.github/workflows/build_flang.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,8 @@ jobs:
2121
cc: [clang]
2222
cpp: [clang++]
2323
version: [10, 11]
24-
llvm_branch: [release_100, release_11x, release_12x]
24+
llvm_branch: [release_11x, release_12x]
2525
include:
26-
- target: X86
27-
cc: gcc
28-
cpp: g++
29-
version: 10
30-
llvm_branch: release_100
3126
- target: X86
3227
cc: gcc
3328
cpp: g++

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ elseif (${TARGET_ARCHITECTURE} MATCHES "^(aarch64|arm64)$")
4646
set(TARGET_ARCHITECTURE aarch64)
4747
set(ARCHNAME aarch64)
4848
set(ARCH ARM)
49+
set(TARGET_SUPPORTS_QUADFP True)
4950
elseif( ${TARGET_ARCHITECTURE} STREQUAL "ppc64le" )
5051
set(ARCHNAME ppc64le)
5152
set(ARCH POWER)

include/flang/ArgParser/arg_parser.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void destroy_arg_parser(arg_parser_t **parser);
5858
* \param default_value value to intialize the target
5959
*/
6060
void register_string_arg(arg_parser_t *parser, const char *arg_name,
61-
char **target, const char *default_value);
61+
const char **target, const char *default_value);
6262

6363
/** \brief Register a string list argument
6464
*
@@ -91,7 +91,7 @@ void register_string_list_arg(arg_parser_t *parser, const char *arg_name,
9191
*/
9292
void register_combined_bool_string_arg(arg_parser_t *parser,
9393
const char *arg_name, bool *bool_target,
94-
char **string_target);
94+
const char **string_target);
9595

9696
/** \brief Register an integer argument
9797
*
@@ -205,7 +205,7 @@ void register_action_map_arg(arg_parser_t *parser, const char *arg_name,
205205
* \param parser argument parser data structure
206206
* \param target location to set the result (pointer to the string)
207207
*/
208-
void register_filename_arg(arg_parser_t *parser, char **target);
208+
void register_filename_arg(arg_parser_t *parser, const char **target);
209209

210210
/** \brief Parse arguments
211211
*

include/flang/Error/pgerror.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ char * getDeduceStr(char * ptoken);
5555
* active in both debug and release builds, and expands to a statement,
5656
* not an expression.
5757
*/
58+
void interr(const char *txt, int val, enum error_severity sev);
5859
#define assert(cond, txt, val, sev) \
5960
if (cond) \
6061
; \

include/legacy-util-api.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ extern "C" {
3131
#include <stdlib.h>
3232
#include <string.h>
3333
#include <time.h> /* time() */
34+
#ifndef _WIN64
3435
#include <unistd.h> /* getcwd() */
35-
36-
/* See tmpfile(3). */
37-
FILE *tmpf(char *ignored);
36+
#else
37+
#include <direct.h>
38+
#endif
3839

3940
/* Copy to 'basename' the final path component, less any undesirable suffix. */
4041
void basenam(const char *orig_path, const char *optional_suffix,

lib/ArgParser/arg_parser.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ struct arg_parser_ {
2929
* continue parsing */
3030
bool fail_on_unknown_args;
3131
/** Where to write input file name */
32-
char **input_file_name_ptr;
32+
const char **input_file_name_ptr;
3333
};
3434

3535
/** \brief Link a bool * and a char ** value together */
3636
typedef struct bool_string_ {
3737
bool *bool_ptr;
38-
char **string_ptr;
38+
const char **string_ptr;
3939
} bool_string_t;
4040

4141
/** \brief Combine input and output for action map arguments */
4242
typedef struct action_map_bundle_ {
43-
action_map_t *input;
43+
const action_map_t *input;
4444
action_map_t *output;
4545
} action_map_bundle_t;
4646

@@ -129,11 +129,11 @@ deallocate_arg_value(hash_key_t key, hash_data_t value_ptr, void *key_context)
129129

130130
/** Register a string argument */
131131
void
132-
register_string_arg(arg_parser_t *parser, const char *arg_name, char **target,
133-
const char *default_value)
132+
register_string_arg(arg_parser_t *parser, const char *arg_name,
133+
const char **target, const char *default_value)
134134
{
135135
/* Set default value */
136-
*target = (char *)default_value;
136+
*target = default_value;
137137

138138
#pragma GCC diagnostic push
139139
#pragma GCC diagnostic warning "-Wcast-qual"
@@ -189,7 +189,7 @@ register_boolean_arg(arg_parser_t *parser, const char *arg_name, bool *target,
189189
/** Register a combines bool and string argument */
190190
void
191191
register_combined_bool_string_arg(arg_parser_t *parser, const char *arg_name,
192-
bool *bool_target, char **string_target)
192+
bool *bool_target, const char **string_target)
193193
{
194194
/* Boolean target defaults to false (not set) */
195195
*bool_target = false;
@@ -252,15 +252,15 @@ register_action_map_arg(arg_parser_t *parser, const char *arg_name,
252252
{
253253
action_map_bundle_t *value = (action_map_bundle_t*) malloc(
254254
sizeof(action_map_bundle_t));
255-
value->input = (action_map_t *)input;
255+
value->input = input;
256256
value->output = target;
257257

258258
add_generic_argument(parser, arg_name, ARG_ActionMap, (void *)value);
259259
}
260260

261261
/** Register input file name */
262262
void
263-
register_filename_arg(arg_parser_t *parser, char **target)
263+
register_filename_arg(arg_parser_t *parser, const char **target)
264264
{
265265
parser->input_file_name_ptr = target;
266266
}
@@ -359,7 +359,7 @@ parse_arguments(const arg_parser_t *parser, int argc, char **argv)
359359
/* Parse argument type */
360360
switch (value->type) {
361361
case ARG_ActionMap: {
362-
action_map_t *from = ((action_map_bundle_t *)value->location)->input;
362+
const action_map_t *from = ((action_map_bundle_t *)value->location)->input;
363363
action_map_t *to = ((action_map_bundle_t *)value->location)->output;
364364

365365
/* TODO parse lists of arguments */

lib/scutil/path-utils.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,6 @@ fndpath(const char *target, char *path, size_t max_length, const char *dirlist)
9595
return -1;
9696
}
9797

98-
FILE *
99-
tmpf(char *ignored)
100-
{
101-
return tmpfile();
102-
}
103-
10498
char *
10599
mkperm(char *pattern, const char *oldext, const char *newext)
106100
{

runtime/flang/allo.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,9 +391,8 @@ I8(__alloc04)(__NELEM_T nelem, dtype kind, size_t len,
391391
if (*pointer && I8(__fort_allocated)(*pointer)
392392
&& ISPRESENT(stat) && *stat == 2) {
393393
int i;
394-
char *mp;
394+
const char *mp = "array already allocated";
395395
MP_P_STDIO;
396-
mp = "array already allocated";
397396
for (i = 0; i < errlen; i++)
398397
errmsg[i] = (*mp ? *mp++ : ' ');
399398
MP_V_STDIO;

runtime/flang/atol.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ __fort_atol(char *p)
3636
}
3737

3838
long
39-
__fort_strtol(char *str, char **ptr, int base)
39+
__fort_strtol(const char *str, char **ptr, int base)
4040
{
4141
long val;
4242
char *end;
@@ -61,7 +61,7 @@ __fort_strtol(char *str, char **ptr, int base)
6161
}
6262
} else {
6363
val = 0;
64-
end = str;
64+
end = NULL;
6565
}
6666
if (ptr)
6767
*ptr = end;

runtime/flang/cnfg.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,16 @@ extern char *__fort_getenv();
3131
* Default is 1 (VAX-style)
3232
*/
3333

34-
FIO_CNFG __fortio_cnfg_ = {
35-
/* ending '_' so it can be accessed by user */
36-
/* default_name */
37-
"fort.%d",
38-
39-
/* vax-style */
40-
1, /* odd => true */
41-
-1, /* internal value of .TRUE. */
34+
FIO_CNFG __fortio_cnfg_ = { /* ending '_' so it can be accessed by user */
35+
"fort.%d", /* default_name */
36+
/* vax-style */
37+
1, /* odd => true */
38+
-1, /* internal value of .TRUE. */
4239
};
4340

4441
/* fio access routines */
4542

46-
char *
43+
const char *
4744
__get_fio_cnfg_default_name(void)
4845
{
4946
return __fortio_cnfg_.default_name;

runtime/flang/cnfg.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212

1313
/* declare structure which may alter the configuration */
1414
typedef struct {
15-
char *default_name; /* sprintf string for default file name */
16-
int true_mask; /* 1 => odd is true, -1 => nonzero is true */
17-
int ftn_true; /* -1 ==> VAX; 1 => unix */
15+
const char *default_name; /* sprintf string for default file name */
16+
int true_mask; /* 1 => odd is true, -1 => nonzero is true */
17+
int ftn_true; /* -1 ==> VAX; 1 => unix */
1818
} FIO_CNFG;
1919

2020
#ifdef WINNT
2121

22-
extern char *__get_fio_cnfg_default_name(void);
22+
extern const char *__get_fio_cnfg_default_name(void);
2323
extern int __get_fio_cnfg_true_mask(void);
2424
extern int *__get_fio_cnfg_true_mask_addr(void);
2525
extern int __get_fio_cnfg_ftn_true(void);

runtime/flang/const.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ int __fort_size_of[__NTYPES] = {
6666
sizeof(__PROCPTR_T), /* F procedure pointer */
6767
};
6868

69-
char *__fort_typenames[__NTYPES] = {
69+
const char *__fort_typenames[__NTYPES] = {
7070
"none", /* no type (absent optional argument) */
7171
"short", /* C signed short */
7272
"unsigned short", /* C unsigned short */
@@ -592,7 +592,7 @@ __get_fort_trues(int idx)
592592
return __fort_trues[idx];
593593
}
594594

595-
char *
595+
const char *
596596
__get_fort_typenames(int idx)
597597
{
598598
return __fort_typenames[idx];
@@ -635,7 +635,7 @@ __set_fort_trues(int idx, void *val)
635635
}
636636

637637
void
638-
__set_fort_typenames(int idx, char *val)
638+
__set_fort_typenames(int idx, const char *val)
639639
{
640640
__fort_typenames[idx] = val;
641641
}

runtime/flang/cplxf.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
#include <unistd.h>
1616
#endif
1717

18-
extern double __fort_second();
19-
extern long __fort_getoptn(char *, long);
20-
2118
/*
2219
* Hacks to return complex-valued functions.
2320
* mergec & mergedc for the Cray are defined in miscsup_com.c.

runtime/flang/curdir.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#endif
2424

2525
extern char *getcwd();
26-
extern char *__fort_getopt();
2726

2827
WIN_MSVCRT_IMP char *WIN_CDECL getenv(const char *);
2928

@@ -32,7 +31,7 @@ WIN_MSVCRT_IMP char *WIN_CDECL getenv(const char *);
3231
void __fort_fixmnt(new, old) char *new;
3332
char *old;
3433
{
35-
char *q;
34+
const char *q;
3635
char s[MAXPATHLEN]; /* substitute patterns */
3736
char *smat; /* match string */
3837
char *srep; /* replace string */
@@ -54,15 +53,13 @@ char *old;
5453
snxt++;
5554
}
5655
srep = strchr(smat, ':'); /* replace string */
57-
if (srep == NULL) {
58-
srep = "";
59-
} else {
56+
if (srep != NULL) {
6057
*srep = '\0';
6158
srep++;
6259
}
6360
n = strlen(smat); /* match string length */
6461
if (strncmp(old, smat, n) == 0) {
65-
strcpy(new, srep);
62+
strcpy(new, srep ? srep : "");
6663
strcat(new, old + n);
6764
return;
6865
}
@@ -95,7 +92,7 @@ void __fort_gethostname(host) char *host;
9592
#ifndef _WIN64
9693
struct utsname un;
9794
#endif
98-
char *p;
95+
const char *p;
9996
int s;
10097

10198
p = __fort_getopt("-curhost");

runtime/flang/dbug.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,16 @@ void I8(__fort_show_section)(F90_Desc *d)
169169
fprintf(__io_stderr(), ")[%d]", F90_GSIZE_G(d));
170170
}
171171

172-
static char *intentnames[4] = {"INOUT", "IN", "OUT", "??"};
172+
static const char *intentnames[4] = {"INOUT", "IN", "OUT", "??"};
173173

174-
static char *specnames[4] = {"OMITTED", "PRESCRIPTIVE", "DESCRIPTIVE",
175-
"TRANSCRIPTIVE"};
174+
static const char *specnames[4] = {"OMITTED", "PRESCRIPTIVE", "DESCRIPTIVE",
175+
"TRANSCRIPTIVE"};
176176

177-
static char *dfmtnames[] = {"*", "BLOCK", "BLOCK", "CYCLIC",
178-
"CYCLIC", "GEN_BLOCK", "INDIRECT"};
177+
static const char *dfmtnames[] = {"*", "BLOCK", "BLOCK", "CYCLIC",
178+
"CYCLIC", "GEN_BLOCK", "INDIRECT"};
179179

180-
static char *dfmtabbrev[] = {"*", "BLK", "BLKK", "CYC", "CYCK", "GENB", "IND"};
180+
static const char *dfmtabbrev[] = {"*", "BLK", "BLKK", "CYC", "CYCK", "GENB",
181+
"IND"};
181182

182183
#if !defined(DESC_I8)
183184

runtime/flang/entry.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ extern __INT_T LINENO[];
3030
/* function stack entry */
3131

3232
struct pent {
33-
char *func; /* function name (no \0) */
34-
__CLEN_T funcl; /* length of above */
35-
char *file; /* file name (no \0) */
36-
__CLEN_T filel; /* length of above */
33+
const char *func; /* function name (no \0) */
34+
__CLEN_T funcl; /* length of above */
35+
const char *file; /* file name (no \0) */
36+
__CLEN_T filel; /* length of above */
3737
int line; /* line number of function entry */
3838
int lines; /* number of lines in function */
3939
int cline; /* calling function line number */
@@ -186,7 +186,7 @@ void ENTFTN(TRACEBACK, traceback)() { __fort_traceback(); }
186186
/* print message with one level call traceback */
187187

188188
void
189-
__fort_tracecall(char *msg)
189+
__fort_tracecall(const char *msg)
190190
{
191191
struct pent *pe;
192192
char buf[512];

runtime/flang/eoshift.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,8 @@ void ENTFTN(EOSHIFTSZ, eoshiftsz)(char *rb, /* result base */
351351

352352
shift = *sb;
353353
dim = *db;
354-
bb = (F90_KIND_G(rs) == __STR) ? " " : (char *)GET_DIST_ZED;
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;
355356

356357
#if defined(DEBUG)
357358
if (__fort_test & DEBUG_EOSH) {
@@ -600,7 +601,8 @@ void ENTFTN(EOSHIFTZ, eoshiftz)(char *rb, /* result base */
600601
__INT_T dim;
601602

602603
dim = *db;
603-
bb = (F90_KIND_G(rs) == __STR) ? " " : (char *)GET_DIST_ZED;
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;
604606
bs = (F90_Desc *)&F90_KIND_G(rs);
605607

606608
#if defined(DEBUG)

0 commit comments

Comments
 (0)