}
void ScopeHandler::SayWithDecl(
const parser::Name &name, const Symbol &symbol, MessageFixedText &&msg) {
- Say2(name, std::move(msg), symbol, "Declaration of '%s'"_en_US);
+ Say2(name, std::move(msg), symbol,
+ symbol.test(Symbol::Flag::Implicit) ? "Implicit declaration of '%s'"_en_US
+ : "Declaration of '%s'"_en_US);
}
void ScopeHandler::SayDerivedType(
const SourceName &name, MessageFixedText &&msg, const Scope &type) {
const parser::Name &name, Symbol::Flag subpFlag) {
auto *symbol{GetSpecificFromGeneric(name)};
if (!symbol) {
+ if (auto *prev{FindSymbol(name)}) {
+ if (prev->attrs().test(Attr::EXTERNAL) &&
+ prev->has<ProcEntityDetails>()) {
+ // this subprogram was previously called, now being declared
+ if (!prev->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,
+ *prev, "Previous call of '%s'"_en_US);
+ }
+ EraseSymbol(name);
+ }
+ }
symbol = &MakeSymbol(name, SubprogramDetails{});
symbol->set(subpFlag);
}
-! Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
+! Copyright (c) 2018-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.
call foo()
end block
end
+
+subroutine s6
+ call a6()
+end
+!ERROR: 'a6' was previously called as a subroutine
+function a6()
+ a6 = 0.0
+end
+
+subroutine s7
+ x = a7()
+end
+!ERROR: 'a7' was previously called as a function
+subroutine a7()
+end
+
+!OK: use of a8 and b8 is consistent
+subroutine s8
+ call a8()
+ x = b8()
+end
+subroutine a8()
+end
+function b8()
+ b8 = 0.0
+end