From d440b2e166b941f317d3211cbe96e82c27c36ec2 Mon Sep 17 00:00:00 2001 From: Peter Steinfeld Date: Tue, 20 Aug 2019 15:17:51 -0700 Subject: [PATCH] [flang] Responses to comments on the pull request: - I removed the redundant test s3() from dosemantics90.f90 - I changed the error messages to state "LOCAL locality-spec" rather than just "locality-spec" - I changed the names of a couple of variables/parameters in check-do.cc to make the code more understandable. Original-commit: flang-compiler/f18@bcc6291e8370d97cb3d4c23a30e676bf3a0012ab Reviewed-on: https://github.com/flang-compiler/f18/pull/663 --- flang/lib/semantics/check-do.cc | 14 +++++++------- flang/test/semantics/dosemantics04.f90 | 4 ++-- flang/test/semantics/dosemantics09.f90 | 18 ++++++------------ 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/flang/lib/semantics/check-do.cc b/flang/lib/semantics/check-do.cc index 6257ee4..e6db1ac 100644 --- a/flang/lib/semantics/check-do.cc +++ b/flang/lib/semantics/check-do.cc @@ -458,7 +458,7 @@ private: SymbolSet GatherLocals( const std::list &localitySpecs) const { SymbolSet symbols; - const Scope &scope{ + const Scope &parentScope{ context_.FindScope(currentStatementSourcePosition_).parent()}; // Loop through the LocalitySpec::Local locality-specs for (const auto &ls : localitySpecs) { @@ -466,7 +466,7 @@ private: // Loop through the names in the Local locality-spec getting their // symbols for (const parser::Name &name : names->v) { - if (const Symbol * symbol{scope.FindSymbol(name.source)}) { + if (const Symbol * symbol{parentScope.FindSymbol(name.source)}) { if (const Symbol * root{GetAssociationRoot(*symbol)}) { symbols.insert(root); } @@ -509,11 +509,11 @@ private: } } - void CheckNoCollisions(const SymbolSet &refs, const SymbolSet &set, + void CheckNoCollisions(const SymbolSet &refs, const SymbolSet &uses, const parser::MessageFixedText &errorMessage, const parser::CharBlock &refPosition) const { for (const Symbol *ref : refs) { - if (set.find(ref) != set.end()) { + if (uses.find(ref) != uses.end()) { const parser::CharBlock &name{ref->name()}; context_.Say(refPosition, errorMessage, name) .Attach(name, "Declaration of '%s'"_en_US, name); @@ -530,13 +530,13 @@ private: expr.thing.thing.value().source); } - // C1129, names in local locality-specs can't be in limit or step expressions + // C1129, names in local locality-specs can't be in mask expressions void CheckMaskDoesNotReferenceLocal( const parser::ScalarLogicalExpr &mask, const SymbolSet &localVars) const { CheckNoCollisions(GatherSymbolsFromExpression(mask.thing.thing.value()), localVars, "concurrent-header mask-expr references variable '%s'" - " in locality-spec"_err_en_US, + " in LOCAL locality-spec"_err_en_US, mask.thing.thing.value().source); } @@ -546,7 +546,7 @@ private: CheckNoCollisions(GatherSymbolsFromExpression(expr.thing.thing.value()), localVars, "concurrent-header expression references variable '%s'" - " in locality-spec"_err_en_US, + " in LOCAL locality-spec"_err_en_US, expr.thing.thing.value().source); } diff --git a/flang/test/semantics/dosemantics04.f90 b/flang/test/semantics/dosemantics04.f90 index fda51a8..8083fe6 100644 --- a/flang/test/semantics/dosemantics04.f90 +++ b/flang/test/semantics/dosemantics04.f90 @@ -18,12 +18,12 @@ PROGRAM dosemantics04 IMPLICIT NONE INTEGER :: a, i, j, k, n -!ERROR: concurrent-header mask-expr references variable 'n' in locality-spec +!ERROR: concurrent-header mask-expr references variable 'n' in LOCAL locality-spec DO CONCURRENT (INTEGER *2 :: i = 1:10, i < j + n) LOCAL(n) PRINT *, "hello" END DO -!ERROR: concurrent-header mask-expr references variable 'a' in locality-spec +!ERROR: concurrent-header mask-expr references variable 'a' in LOCAL locality-spec DO 30 CONCURRENT (i = 1:n:1, j=1:n:2, k=1:n:3, a<3) LOCAL (a) PRINT *, "hello" 30 END DO diff --git a/flang/test/semantics/dosemantics09.f90 b/flang/test/semantics/dosemantics09.f90 index 0f38e8f..7c5871f 100644 --- a/flang/test/semantics/dosemantics09.f90 +++ b/flang/test/semantics/dosemantics09.f90 @@ -31,14 +31,8 @@ subroutine s2() end do end subroutine s2 -subroutine s3() -!ERROR: 'i' is already declared in this scoping unit - do concurrent (i=i:10) shared(i) - end do -end subroutine s3 - subroutine s4() -!ERROR: concurrent-header expression references variable 'i' in locality-spec +!ERROR: concurrent-header expression references variable 'i' in LOCAL locality-spec do concurrent (j=i:10) local(i) end do end subroutine s4 @@ -56,7 +50,7 @@ subroutine s6() end subroutine s6 subroutine s7() -!ERROR: concurrent-header expression references variable 'i' in locality-spec +!ERROR: concurrent-header expression references variable 'i' in LOCAL locality-spec do concurrent (j=1:i) local(i) end do end subroutine s7 @@ -74,7 +68,7 @@ subroutine s9() end subroutine s9 subroutine s10() -!ERROR: concurrent-header expression references variable 'i' in locality-spec +!ERROR: concurrent-header expression references variable 'i' in LOCAL locality-spec do concurrent (j=1:10:i) local(i) end do end subroutine s10 @@ -95,7 +89,7 @@ subroutine s13() ! Test construct-association, in this case, established by the "shared" integer :: ivar associate (avar => ivar) -!ERROR: concurrent-header expression references variable 'ivar' in locality-spec +!ERROR: concurrent-header expression references variable 'ivar' in LOCAL locality-spec do concurrent (j=1:10:avar) local(avar) end do end associate @@ -108,7 +102,7 @@ subroutine s14() ! Test use-association, in this case, established by the "shared" use m1 -!ERROR: concurrent-header expression references variable 'mvar' in locality-spec +!ERROR: concurrent-header expression references variable 'mvar' in LOCAL locality-spec do concurrent (k=mvar:10) local(mvar) end do end subroutine s14 @@ -118,7 +112,7 @@ subroutine s15() ! locality-spec ivar = 3 do concurrent (j=ivar:10) shared(ivar) -!ERROR: concurrent-header expression references variable 'ivar' in locality-spec +!ERROR: concurrent-header expression references variable 'ivar' in LOCAL locality-spec do concurrent (k=ivar:10) local(ivar) end do end do -- 2.7.4