Skip to content

Commit

Permalink
Handle intrinsics declared but not used in host subprogram.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tskeith committed Jul 18, 2017
1 parent cd44bcd commit 524d3eb
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tools/flang1/flang1exe/semant.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ static void save_host(INTERF *);
static void restore_host(INTERF *, LOGICAL);
static void check_end_subprogram(int, int);
static char *name_of_rutype(int);
static void convert_intrinsics_to_idents(void);
static int chk_intrinsic(int, LOGICAL, LOGICAL);
static int create_func_entry(int);
static int create_func_entry_result(int);
Expand Down Expand Up @@ -1447,6 +1448,7 @@ semant1(int rednum, SST *top)
CNULL);
goto executable_shared;
}
convert_intrinsics_to_idents();
save_host(&host_state);
gbl.internal = 1;
restore_host(&host_state, TRUE);
Expand Down Expand Up @@ -11988,6 +11990,23 @@ name_of_rutype(int rutype)
return "";
}

/* If an intrinsic is declared in a host subprogram and not otherwise used,
* convert it to an identifier for the internal subprograms to share.
*/
static void
convert_intrinsics_to_idents()
{
SPTR sptr;
assert(gbl.currsub && gbl.internal == 0,
"only applicable for non-internal subprogram", 0, ERR_Severe);
for (sptr = NOSYM + 1; sptr < stb.firstusym; ++sptr) {
if (DCLDG(sptr) && !EXPSTG(sptr) && IS_INTRINSIC(STYPEG(sptr))) {
SPTR new_sptr = newsym(sptr);
STYPEP(new_sptr, ST_IDENT);
}
}
}

/*
* In certain contexts, a new symbol must be created immediately
* if the identifier is an intrinsic rather than relying on newsym().
Expand Down

0 comments on commit 524d3eb

Please sign in to comment.