[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@e81f57fcf5
Reviewed-on: https://github.com/flang-compiler/f18/pull/1031
This commit is contained in:
Pete Steinfeld 2020-02-27 08:49:40 -08:00
parent 657aaf8b8d
commit 84b2909ded
4 changed files with 8 additions and 12 deletions

View File

@ -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()})};

View File

@ -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<std::intmax_t>(*intKind));
}
if (x.length) {
charInfo_.length = GetParamValue(*x.length, common::TypeParamAttr::Len);

View File

@ -198,10 +198,7 @@ bool IsDummy(const Symbol &symbol) {
bool IsStmtFunction(const Symbol &symbol) {
const auto *subprogram{symbol.detailsIf<SubprogramDetails>()};
if (subprogram && subprogram->stmtFunction()) {
return true;
}
return false;
return subprogram && subprogram->stmtFunction();
}
bool IsInStmtFunction(const Symbol &symbol) {

View File

@ -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