// ENTRY's name. We have to replace that symbol in situ to avoid the
// obligation to rewrite symbol pointers in the parse tree.
if (!symbol.test(subpFlag)) {
- Say2(name,
- subpFlag == Symbol::Flag::Function
- ? "'%s' was previously called as a subroutine"_err_en_US
- : "'%s' was previously called as a function"_err_en_US,
- symbol, "Previous call of '%s'"_en_US);
+ // External statements issue an explicit EXTERNAL attribute.
+ if (symbol.attrs().test(Attr::EXTERNAL) &&
+ !symbol.implicitAttrs().test(Attr::EXTERNAL)) {
+ // Warn if external statement previously declared.
+ Say(name,
+ "EXTERNAL attribute was already specified on '%s'"_warn_en_US);
+ } else {
+ Say2(name,
+ subpFlag == Symbol::Flag::Function
+ ? "'%s' was previously called as a subroutine"_err_en_US
+ : "'%s' was previously called as a function"_err_en_US,
+ symbol, "Previous call of '%s'"_en_US);
+ }
}
EntityDetails entity;
if (proc->type()) {
for (const auto &name : x.v) {
auto *symbol{FindSymbol(name)};
if (!ConvertToProcEntity(DEREF(symbol))) {
- SayWithDecl(
- name, *symbol, "EXTERNAL attribute not allowed on '%s'"_err_en_US);
+ // Check if previous symbol is an interface.
+ if (auto *details{symbol->detailsIf<SubprogramDetails>()}) {
+ if (details->isInterface()) {
+ // Warn if interface previously declared.
+ Say(name,
+ "EXTERNAL attribute was already specified on '%s'"_warn_en_US);
+ }
+ } else {
+ SayWithDecl(
+ name, *symbol, "EXTERNAL attribute not allowed on '%s'"_err_en_US);
+ }
} else if (symbol->attrs().test(Attr::INTRINSIC)) { // C840
Say(symbol->name(),
"Symbol '%s' cannot have both INTRINSIC and EXTERNAL attributes"_err_en_US,