[flang-commits] [flang] 2445a96 - [flang] Enforce F'2023 C1520 correctly (#82842)
via flang-commits
flang-commits at lists.llvm.org
Fri Mar 1 16:49:47 PST 2024
Author: Peter Klausler
Date: 2024-03-01T16:49:43-08:00
New Revision: 2445a96ff2bd038295b313ee15d0d9ec3d033dbf
URL: https://github.com/llvm/llvm-project/commit/2445a96ff2bd038295b313ee15d0d9ec3d033dbf
DIFF: https://github.com/llvm/llvm-project/commit/2445a96ff2bd038295b313ee15d0d9ec3d033dbf.diff
LOG: [flang] Enforce F'2023 C1520 correctly (#82842)
When a procedure declaration statement has a binding label, it must
declare no more than one procedure.
Fixes https://github.com/llvm/llvm-project/issues/82528.
Added:
Modified:
flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/bind-c04.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 7fa9b0d8459c04..b7b46257169e36 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -1118,7 +1118,6 @@ class DeclarationVisitor : public ArraySpecVisitor,
// Set when walking DATA & array constructor implied DO loop bounds
// to warn about use of the implied DO intex therein.
std::optional<SourceName> checkIndexUseInOwnBounds_;
- bool hasBindCName_{false};
bool isVectorType_{false};
UnorderedSymbolSet mustBeScalar_;
@@ -5589,7 +5588,10 @@ bool DeclarationVisitor::Pre(const parser::ProcedureDeclarationStmt &x) {
for (const parser::ProcAttrSpec &procAttr : procAttrSpec) {
if (auto *bindC{std::get_if<parser::LanguageBindingSpec>(&procAttr.u)}) {
if (bindC->v.has_value()) {
- hasBindCName_ = true;
+ if (std::get<std::list<parser::ProcDecl>>(x.t).size() > 1) {
+ Say(context().location().value(),
+ "A procedure declaration statement with a binding name may not declare multiple procedures"_err_en_US);
+ }
break;
}
}
@@ -5598,7 +5600,6 @@ bool DeclarationVisitor::Pre(const parser::ProcedureDeclarationStmt &x) {
}
void DeclarationVisitor::Post(const parser::ProcedureDeclarationStmt &) {
interfaceName_ = nullptr;
- hasBindCName_ = false;
EndDecl();
}
bool DeclarationVisitor::Pre(const parser::DataComponentDefStmt &x) {
diff --git a/flang/test/Semantics/bind-c04.f90 b/flang/test/Semantics/bind-c04.f90
index a4aaffb239fde2..27119e375ce057 100644
--- a/flang/test/Semantics/bind-c04.f90
+++ b/flang/test/Semantics/bind-c04.f90
@@ -19,7 +19,7 @@ subroutine aproc2() bind(c) ! ok
end
end interface
- !Acceptable (as an extension)
+ !ERROR: A procedure declaration statement with a binding name may not declare multiple procedures
procedure(proc), bind(c, name="aaa") :: pc1, pc2
!ERROR: A procedure pointer may not have a BIND attribute with a name
More information about the flang-commits
mailing list