Skip to content

Commit 524d3eb

Browse files
committed
Handle intrinsics declared but not used in host subprogram.
When we reach the CONTAINS of a host subprogram, if there are intrinsic symbols that have been declared by not otherwise used, they must be treated as normal identifiers. This ensures that internal subprograms are consistent in how they treat them.
1 parent cd44bcd commit 524d3eb

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tools/flang1/flang1exe/semant.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ static void save_host(INTERF *);
5555
static void restore_host(INTERF *, LOGICAL);
5656
static void check_end_subprogram(int, int);
5757
static char *name_of_rutype(int);
58+
static void convert_intrinsics_to_idents(void);
5859
static int chk_intrinsic(int, LOGICAL, LOGICAL);
5960
static int create_func_entry(int);
6061
static int create_func_entry_result(int);
@@ -1447,6 +1448,7 @@ semant1(int rednum, SST *top)
14471448
CNULL);
14481449
goto executable_shared;
14491450
}
1451+
convert_intrinsics_to_idents();
14501452
save_host(&host_state);
14511453
gbl.internal = 1;
14521454
restore_host(&host_state, TRUE);
@@ -11988,6 +11990,23 @@ name_of_rutype(int rutype)
1198811990
return "";
1198911991
}
1199011992

11993+
/* If an intrinsic is declared in a host subprogram and not otherwise used,
11994+
* convert it to an identifier for the internal subprograms to share.
11995+
*/
11996+
static void
11997+
convert_intrinsics_to_idents()
11998+
{
11999+
SPTR sptr;
12000+
assert(gbl.currsub && gbl.internal == 0,
12001+
"only applicable for non-internal subprogram", 0, ERR_Severe);
12002+
for (sptr = NOSYM + 1; sptr < stb.firstusym; ++sptr) {
12003+
if (DCLDG(sptr) && !EXPSTG(sptr) && IS_INTRINSIC(STYPEG(sptr))) {
12004+
SPTR new_sptr = newsym(sptr);
12005+
STYPEP(new_sptr, ST_IDENT);
12006+
}
12007+
}
12008+
}
12009+
1199112010
/*
1199212011
* In certain contexts, a new symbol must be created immediately
1199312012
* if the identifier is an intrinsic rather than relying on newsym().

0 commit comments

Comments
 (0)