[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:
peter klausler 2020-01-13 15:13:09 -08:00
parent efa2ec7670
commit c2bdc144c5
4 changed files with 10 additions and 6 deletions

View file

@ -118,6 +118,7 @@ Extensions, deletions, and legacy features supported by default
allowed. The values are normalized.
* An effectively empty source file (no program unit) is accepted and
produces an empty relocatable output file.
* A `RETURN` statement may appear in a main program.
Extensions supported when enabled by options
--------------------------------------------

View file

@ -28,7 +28,7 @@ ENUM_CLASS(LanguageFeature, BackslashEscapes, OldDebugLines,
CruftAfterAmpersand, ClassicCComments, AdditionalFormats, BigIntLiterals,
RealDoControls, EquivalenceNumericWithCharacter, AdditionalIntrinsics,
AnonymousParents, OldLabelDoEndStatements, LogicalIntegerAssignment,
EmptySourceFile)
EmptySourceFile, ProgramReturn)
using LanguageFeatures = EnumSet<LanguageFeature, LanguageFeature_enumSize>;

View file

@ -31,11 +31,13 @@ void ReturnStmtChecker::Leave(const parser::ReturnStmt &returnStmt) {
// subroutine subprogram.
const auto &scope{context_.FindScope(context_.location().value())};
if (const auto *subprogramScope{FindContainingSubprogram(scope)}) {
if (returnStmt.v && subprogramScope->kind() == Scope::Kind::Subprogram) {
if (IsFunction(*subprogramScope->GetSymbol())) {
if (returnStmt.v &&
(subprogramScope->kind() == Scope::Kind::MainProgram ||
IsFunction(*subprogramScope->GetSymbol()))) {
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);
}
}
}

View file

@ -126,6 +126,7 @@ set(ERROR_TESTS
# altreturn02.f90
# altreturn03.f90
altreturn04.f90
altreturn05.f90
allocate01.f90
allocate02.f90
allocate03.f90