From 84b2909dedf4c6e03c431e47b6a2a5b23ced4c00 Mon Sep 17 00:00:00 2001 From: Pete Steinfeld Date: Thu, 27 Feb 2020 08:49:40 -0800 Subject: [PATCH] [flang] Responses to pull request comments I cleaned up some code and reverted a change to semantic checking for the exponent letter in REAL literals. Original-commit: flang-compiler/f18@e81f57fcf54ee0493044d53a6d1bf05f661e2660 Reviewed-on: https://github.com/flang-compiler/f18/pull/1031 --- flang/lib/Semantics/expression.cpp | 8 +++++--- flang/lib/Semantics/resolve-names.cpp | 3 ++- flang/lib/Semantics/tools.cpp | 5 +---- flang/test/Semantics/kinds04.f90 | 4 ---- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/flang/lib/Semantics/expression.cpp b/flang/lib/Semantics/expression.cpp index 5c1a040d1074..a09b1ac62558 100644 --- a/flang/lib/Semantics/expression.cpp +++ b/flang/lib/Semantics/expression.cpp @@ -524,10 +524,12 @@ MaybeExpr ExpressionAnalyzer::Analyze(const parser::RealLiteralConstant &x) { if (letterKind) { defaultKind = *letterKind; } + // C716 requires 'E' as an exponent, but this is more useful auto kind{AnalyzeKindParam(x.kind, defaultKind)}; - if (x.kind && letterKind && expoLetter != 'e') { // C716 - Say("Explicit kind parameter on REAL constant can only be used with" - " exponent letter 'E'"_err_en_US); + if (letterKind && kind != *letterKind && expoLetter != 'e') { + Say("Explicit kind parameter on real constant disagrees with " + "exponent letter '%c'"_en_US, + expoLetter); } auto result{common::SearchTypes( RealTypeVisitor{kind, x.real.source, GetFoldingContext()})}; diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp index 670cec7ed970..3cb31c9484b9 100644 --- a/flang/lib/Semantics/resolve-names.cpp +++ b/flang/lib/Semantics/resolve-names.cpp @@ -3277,7 +3277,8 @@ void DeclarationVisitor::Post(const parser::CharSelector::LengthAndKind &x) { !evaluate::IsValidKindOfIntrinsicType( TypeCategory::Character, *intKind)) { // C715, C719 Say(currStmtSource().value(), - "KIND value (%jd) not valid for CHARACTER"_err_en_US, *intKind); + "KIND value (%jd) not valid for CHARACTER"_err_en_US, + static_cast(*intKind)); } if (x.length) { charInfo_.length = GetParamValue(*x.length, common::TypeParamAttr::Len); diff --git a/flang/lib/Semantics/tools.cpp b/flang/lib/Semantics/tools.cpp index d5fc39c987b6..57980dd76875 100644 --- a/flang/lib/Semantics/tools.cpp +++ b/flang/lib/Semantics/tools.cpp @@ -198,10 +198,7 @@ bool IsDummy(const Symbol &symbol) { bool IsStmtFunction(const Symbol &symbol) { const auto *subprogram{symbol.detailsIf()}; - if (subprogram && subprogram->stmtFunction()) { - return true; - } - return false; + return subprogram && subprogram->stmtFunction(); } bool IsInStmtFunction(const Symbol &symbol) { diff --git a/flang/test/Semantics/kinds04.f90 b/flang/test/Semantics/kinds04.f90 index a44c62bae47e..ecf3a446cc3d 100644 --- a/flang/test/Semantics/kinds04.f90 +++ b/flang/test/Semantics/kinds04.f90 @@ -6,9 +6,7 @@ subroutine s(var) real :: realvar1 = 4.0E6_4 real :: realvar2 = 4.0D6 real :: realvar3 = 4.0Q6 - !ERROR: Explicit kind parameter on REAL constant can only be used with exponent letter 'E' real :: realvar4 = 4.0D6_8 - !ERROR: Explicit kind parameter on REAL constant can only be used with exponent letter 'E' real :: realvar5 = 4.0Q6_16 real :: realvar6 = 4.0E6_8 real :: realvar7 = 4.0E6_10 @@ -19,9 +17,7 @@ subroutine s(var) double precision :: doublevar1 = 4.0E6_4 double precision :: doublevar2 = 4.0D6 double precision :: doublevar3 = 4.0Q6 - !ERROR: Explicit kind parameter on REAL constant can only be used with exponent letter 'E' double precision :: doublevar4 = 4.0D6_8 - !ERROR: Explicit kind parameter on REAL constant can only be used with exponent letter 'E' double precision :: doublevar5 = 4.0Q6_16 double precision :: doublevar6 = 4.0E6_8 double precision :: doublevar7 = 4.0E6_10