[flang] More comments addressed
Original-commit: flang-compiler/f18@9c863a572b Reviewed-on: https://github.com/flang-compiler/f18/pull/926 Tree-same-pre-rewrite: false
This commit is contained in:
parent
efa2ec7670
commit
c2bdc144c5
@ -118,6 +118,7 @@ Extensions, deletions, and legacy features supported by default
|
|||||||
allowed. The values are normalized.
|
allowed. The values are normalized.
|
||||||
* An effectively empty source file (no program unit) is accepted and
|
* An effectively empty source file (no program unit) is accepted and
|
||||||
produces an empty relocatable output file.
|
produces an empty relocatable output file.
|
||||||
|
* A `RETURN` statement may appear in a main program.
|
||||||
|
|
||||||
Extensions supported when enabled by options
|
Extensions supported when enabled by options
|
||||||
--------------------------------------------
|
--------------------------------------------
|
||||||
|
@ -28,7 +28,7 @@ ENUM_CLASS(LanguageFeature, BackslashEscapes, OldDebugLines,
|
|||||||
CruftAfterAmpersand, ClassicCComments, AdditionalFormats, BigIntLiterals,
|
CruftAfterAmpersand, ClassicCComments, AdditionalFormats, BigIntLiterals,
|
||||||
RealDoControls, EquivalenceNumericWithCharacter, AdditionalIntrinsics,
|
RealDoControls, EquivalenceNumericWithCharacter, AdditionalIntrinsics,
|
||||||
AnonymousParents, OldLabelDoEndStatements, LogicalIntegerAssignment,
|
AnonymousParents, OldLabelDoEndStatements, LogicalIntegerAssignment,
|
||||||
EmptySourceFile)
|
EmptySourceFile, ProgramReturn)
|
||||||
|
|
||||||
using LanguageFeatures = EnumSet<LanguageFeature, LanguageFeature_enumSize>;
|
using LanguageFeatures = EnumSet<LanguageFeature, LanguageFeature_enumSize>;
|
||||||
|
|
||||||
|
@ -31,11 +31,13 @@ void ReturnStmtChecker::Leave(const parser::ReturnStmt &returnStmt) {
|
|||||||
// subroutine subprogram.
|
// subroutine subprogram.
|
||||||
const auto &scope{context_.FindScope(context_.location().value())};
|
const auto &scope{context_.FindScope(context_.location().value())};
|
||||||
if (const auto *subprogramScope{FindContainingSubprogram(scope)}) {
|
if (const auto *subprogramScope{FindContainingSubprogram(scope)}) {
|
||||||
if (returnStmt.v && subprogramScope->kind() == Scope::Kind::Subprogram) {
|
if (returnStmt.v &&
|
||||||
if (IsFunction(*subprogramScope->GetSymbol())) {
|
(subprogramScope->kind() == Scope::Kind::MainProgram ||
|
||||||
context_.Say(
|
IsFunction(*subprogramScope->GetSymbol()))) {
|
||||||
"RETURN with expression is only allowed in SUBROUTINE subprogram"_err_en_US);
|
context_.Say(
|
||||||
}
|
"RETURN with expression is only allowed in SUBROUTINE subprogram"_err_en_US);
|
||||||
|
} else if (context_.ShouldWarn(common::LanguageFeature::ProgramReturn)) {
|
||||||
|
context_.Say("RETURN should not appear in a main program"_en_US);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,6 +126,7 @@ set(ERROR_TESTS
|
|||||||
# altreturn02.f90
|
# altreturn02.f90
|
||||||
# altreturn03.f90
|
# altreturn03.f90
|
||||||
altreturn04.f90
|
altreturn04.f90
|
||||||
|
altreturn05.f90
|
||||||
allocate01.f90
|
allocate01.f90
|
||||||
allocate02.f90
|
allocate02.f90
|
||||||
allocate03.f90
|
allocate03.f90
|
||||||
|
Loading…
x
Reference in New Issue
Block a user