From ca5fee537573179941eddea7e6c15856d5946005 Mon Sep 17 00:00:00 2001 From: "Jinxin (Brian) Yang" Date: Tue, 20 Aug 2019 10:30:29 -0700 Subject: [PATCH] [flang] [OpenMP] miscellaneous parse tree fix (flang-compiler/f18#669) Fix `aligned(argument-list[ : alignment])` for `declare simd` (original implementation will throw parser error if `: alignment` is present. Original-commit: flang-compiler/f18@f3f50f9ad3b77174d0054011a17c8e4d3af50d98 Reviewed-on: https://github.com/flang-compiler/f18/pull/669 --- flang/lib/parser/openmp-grammar.h | 2 +- flang/lib/semantics/check-omp-structure.cc | 10 ++++++++++ flang/test/semantics/omp-declarative-directive.f90 | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/flang/lib/parser/openmp-grammar.h b/flang/lib/parser/openmp-grammar.h index 1be7b85..c3f84b8 100644 --- a/flang/lib/parser/openmp-grammar.h +++ b/flang/lib/parser/openmp-grammar.h @@ -156,7 +156,7 @@ TYPE_CONTEXT_PARSER("Omp LINEAR clause"_en_US, // ALIGNED(list: alignment) TYPE_PARSER(construct( - nonemptyList(name), maybe(":"_tok) >> scalarIntConstantExpr)) + nonemptyList(name), maybe(":" >> scalarIntConstantExpr))) TYPE_PARSER(construct(pure(OmpObject::Kind::Object), designator) || construct( diff --git a/flang/lib/semantics/check-omp-structure.cc b/flang/lib/semantics/check-omp-structure.cc index 19e0f05..b382d2c 100644 --- a/flang/lib/semantics/check-omp-structure.cc +++ b/flang/lib/semantics/check-omp-structure.cc @@ -276,6 +276,16 @@ void OmpStructureChecker::Enter(const parser::OmpEndSectionsDirective &x) { void OmpStructureChecker::Enter(const parser::OpenMPDeclareSimdConstruct &x) { const auto &dir{std::get(x.t)}; PushContext(dir.source, OmpDirective::DECLARE_SIMD); + // 2.8.2 declare-simd-clause -> simdlen-clause | + // linear-clause | + // aligned-clause | + // uniform-clause | + // inbranch-clause | + // notinbranch-clause + OmpClauseSet allowed{OmpClause::LINEAR, OmpClause::ALIGNED, + OmpClause::UNIFORM, OmpClause::INBRANCH, OmpClause::NOTINBRANCH}; + SetContextAllowed(allowed); + SetContextAllowedOnce({OmpClause::SIMDLEN}); } void OmpStructureChecker::Leave(const parser::OpenMPDeclareSimdConstruct &) { diff --git a/flang/test/semantics/omp-declarative-directive.f90 b/flang/test/semantics/omp-declarative-directive.f90 index 01739f5..a8cf5ea 100644 --- a/flang/test/semantics/omp-declarative-directive.f90 +++ b/flang/test/semantics/omp-declarative-directive.f90 @@ -24,7 +24,8 @@ subroutine declare_simd_1(a, b) real(8), intent(inout) :: a, b !ERROR: Internal: no symbol found for 'declare_simd_1' - !$omp declare simd(declare_simd_1) + !ERROR: Internal: no symbol found for 'a' + !$omp declare simd(declare_simd_1) aligned(a) a = 3.14 + b end subroutine declare_simd_1 -- 2.7.4