diff --git a/lang/m2/comp/enter.c b/lang/m2/comp/enter.c index 6994d414..0c772324 100644 --- a/lang/m2/comp/enter.c +++ b/lang/m2/comp/enter.c @@ -255,8 +255,18 @@ ImportEffects(idef, scope, flag) /* Also import all enumeration literals */ for (df = tp->enm_enums; df; df = df->enm_next) { + /* But be careful; we could have a situation where f.i. + different subrange types of the enumeration type + are imported. If the literal is already imported + in some way, don't do it again; we don't want + a multiple defined error message here. + */ + t_def *df1; + df->df_flags |= D_QEXPORTED; - if (! DoImport(df, scope, flag|D_USED)) assert(0); + if ((!(df1 = lookup(df->df_idf, scope, D_IMPORT, 0)) || + df1 != df) && + ! DoImport(df, scope, flag|D_USED)) assert(0); /* don't complain when not used ... */ } idef->df_flags |= D_USED; /* don't complain ... */