[flang] Fixed situations where multiple error messages were being emitted.

Original-commit: flang-compiler/f18@ac62cfa9cd
Reviewed-on: https://github.com/flang-compiler/f18/pull/478
This commit is contained in:
Peter Steinfeld 2019-06-10 15:10:32 -07:00
parent c97f17a59f
commit 609e2d753b
2 changed files with 2 additions and 10 deletions

View File

@ -417,9 +417,7 @@ private:
void CheckDoVariable(const parser::ScalarName &scalarName) {
const parser::CharBlock &sourceLocation{scalarName.thing.source};
const Symbol *symbol{scalarName.thing.symbol};
if (!symbol) {
SayBadDoControl(sourceLocation);
} else {
if (symbol) {
if (!IsVariableName(*symbol)) {
context_.Say(
sourceLocation, "DO control must be an INTEGER variable"_err_en_US);
@ -441,9 +439,7 @@ private:
const evaluate::Expr<evaluate::SomeType> *expr{GetExpr(scalarExpression)};
const parser::CharBlock &sourceLocation{
scalarExpression.thing.value().source};
if (!expr) {
SayBadDoControl(sourceLocation);
} else {
if (expr) {
if (ExprHasTypeCategory(*expr, TypeCategory::Integer)) {
return; // No warnings or errors for INTEGER
}

View File

@ -149,7 +149,6 @@ PROGRAM do_issue_458
! Undeclared DO variable
!ERROR: No explicit type declared for 'undeclared'
!ERROR: DO controls should be INTEGER
DO undeclared = 1, 10, 3
PRINT *, "plvar is: ", plvar
END DO
@ -220,7 +219,6 @@ PROGRAM do_issue_458
END DO
! Invalid initial expression
!ERROR: DO controls should be INTEGER
!ERROR: Integer literal is too large for INTEGER(KIND=4)
DO ivar = -2147483648_4, 10, 3
PRINT *, "ivar is: ", ivar
@ -259,7 +257,6 @@ PROGRAM do_issue_458
END DO
! Invalid final expression
!ERROR: DO controls should be INTEGER
!ERROR: Integer literal is too large for INTEGER(KIND=4)
DO ivar = 1, -2147483648_4, 3
PRINT *, "ivar is: ", ivar
@ -298,7 +295,6 @@ PROGRAM do_issue_458
END DO
! Invalid step expression
!ERROR: DO controls should be INTEGER
!ERROR: Integer literal is too large for INTEGER(KIND=4)
DO ivar = 1, 10, -2147483648_4
PRINT *, "ivar is: ", ivar