diff options
author | Peter Klausler <35819229+klausler@users.noreply.github.com> | 2024-03-01 16:49:43 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-01 16:49:43 -0800 |
commit | 2445a96ff2bd038295b313ee15d0d9ec3d033dbf (patch) | |
tree | ea982138641c509e07d1215728da3c1f88bd09e8 | |
parent | f4215f71402dccc9c6a6f7ad51bbc1d08c4a48c2 (diff) | |
download | llvm-2445a96ff2bd038295b313ee15d0d9ec3d033dbf.zip llvm-2445a96ff2bd038295b313ee15d0d9ec3d033dbf.tar.gz llvm-2445a96ff2bd038295b313ee15d0d9ec3d033dbf.tar.bz2 |
[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.
-rw-r--r-- | flang/lib/Semantics/resolve-names.cpp | 7 | ||||
-rw-r--r-- | flang/test/Semantics/bind-c04.f90 | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp index 7fa9b0d..b7b4625 100644 --- a/flang/lib/Semantics/resolve-names.cpp +++ b/flang/lib/Semantics/resolve-names.cpp @@ -1118,7 +1118,6 @@ private: // 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 a4aaffb..27119e3 100644 --- a/flang/test/Semantics/bind-c04.f90 +++ b/flang/test/Semantics/bind-c04.f90 @@ -19,7 +19,7 @@ subroutine sub(x, y) 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 |