Skip to content

Commit 54e67ef

Browse files
tskeithschweitzpgi
authored andcommitted
[flang] Add more support for alternate returns
Add `hasAlternateReturns` to `evaluate::ProcedureRef`. Add `HasAlternateReturns` to test subprogram symbols. Fix `label01.F90` test: It was checking that "error: " didn't appear in the output. But that was erroneously matching a warning that ends "would be in error:". So change it to check for ": error: " instead. Differential Revision: https://reviews.llvm.org/D83007
1 parent beedb3b commit 54e67ef

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

flang/include/flang/Evaluate/call.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,10 @@ struct ProcedureDesignator {
190190
class ProcedureRef {
191191
public:
192192
CLASS_BOILERPLATE(ProcedureRef)
193-
ProcedureRef(ProcedureDesignator &&p, ActualArguments &&a, bool alt = false)
194-
: proc_{std::move(p)}, arguments_{std::move(a)}, hasAlternateReturns_{
195-
alt} {}
193+
ProcedureRef(ProcedureDesignator &&p, ActualArguments &&a,
194+
bool hasAlternateReturns = false)
195+
: proc_{std::move(p)}, arguments_{std::move(a)},
196+
hasAlternateReturns_{hasAlternateReturns} {}
196197
~ProcedureRef();
197198

198199
ProcedureDesignator &proc() { return proc_; }
@@ -203,7 +204,7 @@ class ProcedureRef {
203204
std::optional<Expr<SubscriptInteger>> LEN() const;
204205
int Rank() const;
205206
bool IsElemental() const { return proc_.IsElemental(); }
206-
bool HasAlternateReturns() const { return hasAlternateReturns_; }
207+
bool hasAlternateReturns() const { return hasAlternateReturns_; }
207208
bool operator==(const ProcedureRef &) const;
208209
llvm::raw_ostream &AsFortran(llvm::raw_ostream &) const;
209210

flang/include/flang/Semantics/tools.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ bool IsInitialized(const Symbol &, bool ignoreDATAstatements = false);
100100
bool HasIntrinsicTypeName(const Symbol &);
101101
bool IsSeparateModuleProcedureInterface(const Symbol *);
102102
bool IsAutomatic(const Symbol &);
103-
// Given a subroutine symbol, tells if the subroutine has alternate returns
104103
bool HasAlternateReturns(const Symbol &);
105104

106105
// Return an ultimate component of type that matches predicate, or nullptr.

flang/lib/Semantics/expression.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,6 +2020,8 @@ void ExpressionAnalyzer::Analyze(const parser::CallStmt &callStmt) {
20202020
ProcedureDesignator *proc{std::get_if<ProcedureDesignator>(&callee->u)};
20212021
CHECK(proc);
20222022
if (CheckCall(call.source, *proc, callee->arguments)) {
2023+
bool hasAlternateReturns{
2024+
analyzer.GetActuals().size() < actualArgList.size()};
20232025
callStmt.typedCall.reset(new ProcedureRef{std::move(*proc),
20242026
std::move(callee->arguments), hasAlternateReturns});
20252027
}

flang/lib/Semantics/tools.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,9 +1292,9 @@ void LabelEnforce::SayWithConstruct(SemanticsContext &context,
12921292
.Attach(constructLocation, GetEnclosingConstructMsg());
12931293
}
12941294

1295-
bool HasAlternateReturns(const Symbol &sub) {
1296-
for (const auto *args : sub.get<SubprogramDetails>().dummyArgs()) {
1297-
if (!args) {
1295+
bool HasAlternateReturns(const Symbol &subprogram) {
1296+
for (const auto *dummyArg : subprogram.get<SubprogramDetails>().dummyArgs()) {
1297+
if (!dummyArg) {
12981298
return true;
12991299
}
13001300
}

flang/test/Semantics/label01.F90

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
! RUN: %f18 -funparse-with-symbols -DSTRICT_F18 -Mstandard %s 2>&1 | FileCheck %s
22
! RUN: %f18 -funparse-with-symbols -DARCHAIC_FORTRAN %s 2>&1 | FileCheck %s
3-
! CHECK-NOT: error:{{[[:space:]]}}
3+
! CHECK-NOT: :{{[[:space:]]}}error:{{[[:space:]]}}
44
! FIXME: the above check line does not work because diags are not emitted with error: in them.
55

66
! these are the conformance tests
77
! define STRICT_F18 to eliminate tests of features not in F18
88
! define ARCHAIC_FORTRAN to add test of feature found in Fortran before F95
99

10-
1110
subroutine sub00(a,b,n,m)
1211
integer :: n, m
1312
real a(n)

0 commit comments

Comments
 (0)