[flang-commits] [PATCH] D132165: [flang] Improve error message for attempted assignment to a procedure
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Thu Aug 18 15:23:28 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG07f2cd6d0418: [flang] Improve error message for attempted assignment to a procedure (authored by klausler).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132165/new/
https://reviews.llvm.org/D132165
Files:
flang/lib/Semantics/expression.cpp
flang/test/Semantics/assign04.f90
Index: flang/test/Semantics/assign04.f90
===================================================================
--- flang/test/Semantics/assign04.f90
+++ flang/test/Semantics/assign04.f90
@@ -117,15 +117,22 @@
end
subroutine s8
- !ERROR: Assignment to subprogram 's8' is not allowed
+ !ERROR: Assignment to procedure 's8' is not allowed
s8 = 1.0
end
real function f9() result(r)
- !ERROR: Assignment to subprogram 'f9' is not allowed
+ !ERROR: Assignment to procedure 'f9' is not allowed
f9 = 1.0
end
+subroutine s9
+ real f9a
+ !ERROR: Assignment to procedure 'f9a' is not allowed
+ f9a = 1.0
+ print *, f9a(1)
+end
+
!ERROR: No explicit type declared for dummy argument 'n'
subroutine s10(a, n)
implicit none
Index: flang/lib/Semantics/expression.cpp
===================================================================
--- flang/lib/Semantics/expression.cpp
+++ flang/lib/Semantics/expression.cpp
@@ -3353,17 +3353,20 @@
if (!symbol) {
context_.SayAt(x, "Assignment to constant '%s' is not allowed"_err_en_US,
x.GetSource());
- } else if (auto *subp{symbol->detailsIf<semantics::SubprogramDetails>()}) {
- auto *msg{context_.SayAt(x,
- "Assignment to subprogram '%s' is not allowed"_err_en_US,
- symbol->name())};
- if (subp->isFunction()) {
- const auto &result{subp->result().name()};
- msg->Attach(result, "Function result is '%s'"_en_US, result);
+ } else if (IsProcedure(*symbol)) {
+ if (auto *msg{context_.SayAt(x,
+ "Assignment to procedure '%s' is not allowed"_err_en_US,
+ symbol->name())}) {
+ if (auto *subp{symbol->detailsIf<semantics::SubprogramDetails>()}) {
+ if (subp->isFunction()) {
+ const auto &result{subp->result().name()};
+ msg->Attach(result, "Function result is '%s'"_en_US, result);
+ }
+ }
}
} else {
- context_.SayAt(x, "Assignment to constant '%s' is not allowed"_err_en_US,
- symbol->name());
+ context_.SayAt(
+ x, "Assignment to '%s' is not allowed"_err_en_US, symbol->name());
}
}
fatalErrors_ = true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132165.453812.patch
Type: text/x-patch
Size: 2173 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220818/3f2ca2af/attachment.bin>
More information about the flang-commits
mailing list