Skip to content

Commit

Permalink
[flang] Enforce F'2023 C1520 correctly (#82842)
Browse files Browse the repository at this point in the history
When a procedure declaration statement has a binding label, it must
declare no more than one procedure.

Fixes #82528.
  • Loading branch information
klausler committed Mar 2, 2024
1 parent f4215f7 commit 2445a96
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions flang/lib/Semantics/resolve-names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_;

Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Semantics/bind-c04.f90
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2445a96

Please sign in to comment.