[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@f3f50f9ad3
Reviewed-on: https://github.com/flang-compiler/f18/pull/669
This commit is contained in:
Jinxin (Brian) Yang 2019-08-20 10:30:29 -07:00 committed by GitHub
parent 39be4ad473
commit ca5fee5375
3 changed files with 13 additions and 2 deletions

View File

@ -156,7 +156,7 @@ TYPE_CONTEXT_PARSER("Omp LINEAR clause"_en_US,
// ALIGNED(list: alignment)
TYPE_PARSER(construct<OmpAlignedClause>(
nonemptyList(name), maybe(":"_tok) >> scalarIntConstantExpr))
nonemptyList(name), maybe(":" >> scalarIntConstantExpr)))
TYPE_PARSER(construct<OmpObject>(pure(OmpObject::Kind::Object), designator) ||
construct<OmpObject>(

View File

@ -276,6 +276,16 @@ void OmpStructureChecker::Enter(const parser::OmpEndSectionsDirective &x) {
void OmpStructureChecker::Enter(const parser::OpenMPDeclareSimdConstruct &x) {
const auto &dir{std::get<parser::Verbatim>(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 &) {

View File

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