Skip to content
Permalink
Browse files

Fix submodule identifier conflict with predefined entity

Add a check to see if the ancestor module has the same name
as some predefined entity. If so, create a new symtab entry.
  • Loading branch information...
gklimowicz committed Mar 1, 2019
1 parent cc0c28d commit 1143111a67c811491116cafcf6afc387716d7955
@@ -1520,3 +1520,5 @@ A DO CONCURRENT variable with LOCAL_INIT locality must have a host variable of t
.MS S 1207 "ERROR STOP stop-code requires either a character or integer expression."
.MS S 1208 "QUIET requires a logical expression."
.MS S 1209 "ERROR STOP stop-code integer expression must be an integer of default kind."
.MS S 1210 "Parent module $ must declare a separate module procedure."
.MS S 1211 "Submodule's ancestor module $ must be a nonintrinsic module."
@@ -5199,6 +5199,7 @@ fill_ST_MODULE(SYMITEM *ps, int sptr)
TYPDP(sptr, TYPDG(0));
PRIVATEP(sptr, PRIVATEG(0));
HAS_TBP_BOUND_TO_SMPP(sptr, HAS_TBP_BOUND_TO_SMPG(0));
HAS_SMP_DECP(sptr, HAS_SMP_DECG(0));
stb.stg_base[0] = save_sym0;

} /* fill_ST_MODULE */
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995-2018, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 1995-2019, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -415,9 +415,13 @@ apply_use_stmts(void)
{
int save_lineno;
MODULE_ID m_id;
SPTR ancestor_mod;

ancestor_mod = NOSYM;
module_id = NO_MODULE;

if (ANCESTORG(gbl.currmod))
ancestor_mod = ANCESTORG(gbl.currmod);

/*
* A user error could have occurred which created a situation where
* sem.pgphase is still PHASE_USE (USE statements have appeared) and the
@@ -433,25 +437,33 @@ apply_use_stmts(void)
init_use_tree();
}
if (usedb.base[ISO_C_MOD].module) {
if (usedb.base[ISO_C_MOD].module == ancestor_mod)
error(1211, ERR_Severe, gbl.lineno, SYMNAME(ancestor_mod), CNULL);
/* use iso_c_binding */
add_predefined_isoc_module();
if (sem.interface == 0 && IN_MODULE)
exportb.iso_c_library = TRUE;
apply_use(ISO_C_MOD);
}
if (usedb.base[IEEE_ARITH_MOD].module) {
if (usedb.base[IEEE_ARITH_MOD].module == ancestor_mod)
error(1211, ERR_Severe, gbl.lineno, SYMNAME(ancestor_mod), CNULL);
/* use ieee_arithmetic */
add_predefined_ieeearith_module();
if (sem.interface == 0 && IN_MODULE)
exportb.ieee_arith_library = TRUE;
apply_use(IEEE_ARITH_MOD);
}
if (usedb.base[IEEE_FEATURES_MOD].module) {
if (usedb.base[IEEE_FEATURES_MOD].module == ancestor_mod)
error(1211, ERR_Severe, gbl.lineno, SYMNAME(ancestor_mod), CNULL);
/* use ieee_features */
sem.ieee_features = TRUE;
apply_use(IEEE_FEATURES_MOD);
}
if (usedb.base[ISO_FORTRAN_ENV].module) {
if (usedb.base[ISO_FORTRAN_ENV].module == ancestor_mod)
error(1211, ERR_Severe, gbl.lineno, SYMNAME(ancestor_mod), CNULL);
/* use iso_fortran_env */
add_predefined_iso_fortran_env_module();
if (sem.interface == 0 && IN_MODULE)
@@ -1102,6 +1114,10 @@ SPTR
begin_submodule(SPTR id, SPTR ancestor_mod, SPTR parent_submod, SPTR *parent)
{
SPTR submod;
if (ancestor_mod < stb.firstusym) {
/* if the ancestor module has the same name as some predefined thing */
ancestor_mod = insert_sym(ancestor_mod);
}
if (parent_submod <= NOSYM) {
*parent = ancestor_mod;
} else {
@@ -1527,6 +1527,9 @@ semant1(int rednum, SST *top)
goto statement_shared;
}
if (IN_MODULE) {
if (ANCESTORG(gbl.currmod) && !HAS_SMP_DECG(ANCESTORG(gbl.currmod)))
error(1210, ERR_Severe, gbl.lineno,
SYMNAME(ANCESTORG(gbl.currmod)), CNULL);
fe_save_state();
begin_contains();
sem.pgphase = PHASE_INIT;
@@ -2339,6 +2342,7 @@ semant1(int rednum, SST *top)
* ISSUBMODULEP is used for name mangling.
*/
SEPARATEMPP(sptr, TRUE);
HAS_SMP_DECP(SCOPEG(sptr), TRUE);
if (IN_MODULE)
INMODULEP(sptr, TRUE);
if (SST_FIRSTG(RHS(rhstop))) {
@@ -2518,6 +2518,8 @@ the normal module SUBROUTINE, FUNCTION, and PROCEDURE.
.FL HAS_TBP_BOUND_TO_SMP f112
This flag is set when this module has a derived type with a type bound
procedure that is implemented by a separate module procedure
.FL HAS_SMP_DEC f113
This flag is set on modules that have a separate module procedure declared.
.FL NEEDMOD f1
If set, an external reference to this module needs to be generated,
so a link error will occur if a program that USEs this module is linked

0 comments on commit 1143111

Please sign in to comment.
You can’t perform that action at this time.