Skip to content

Commit dbe9e87

Browse files
Leporacanthicuskiranchandramohan
authored andcommitted
Remove incorrect "begin" keyword.
This is only used in C++, so do not use it in the Fortran compiler. Updated tests to suit.
1 parent 6d4beb3 commit dbe9e87

File tree

10 files changed

+60
-51
lines changed

10 files changed

+60
-51
lines changed

flang/include/flang/Parser/dump-parse-tree.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -673,10 +673,10 @@ class ParseTreeDumper {
673673
NODE(parser, OpenACCStandaloneConstruct)
674674
NODE(parser, OpenACCWaitConstruct)
675675
NODE(parser, OpenMPAssumeConstruct)
676+
NODE(parser, OpenMPDeclarativeAssumes)
677+
NODE(parser, OmpAssumesPartConstruct)
678+
NODE(parser, OmpAssumesDirective)
676679
NODE(parser, OpenMPAssumesConstruct)
677-
NODE(parser, OpenMPAssumesPartConstruct)
678-
NODE(parser, OmpBeginAssumesDirective)
679-
NODE(parser, OpenMPBeginAssumesConstruct)
680680
NODE(parser, OmpEndAssumesDirective)
681681
NODE(parser, OpenMPAtomicConstruct)
682682
NODE(parser, OpenMPBlockConstruct)

flang/include/flang/Parser/parse-tree.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4455,14 +4455,14 @@ struct OpenMPAssumeConstruct {
44554455
CharBlock source;
44564456
};
44574457

4458-
struct OpenMPAssumesConstruct {
4459-
TUPLE_CLASS_BOILERPLATE(OpenMPAssumesConstruct);
4458+
struct OpenMPDeclarativeAssumes {
4459+
TUPLE_CLASS_BOILERPLATE(OpenMPDeclarativeAssumes);
44604460
std::tuple<Verbatim, OmpClauseList> t;
44614461
CharBlock source;
44624462
};
44634463

4464-
struct OmpBeginAssumesDirective {
4465-
TUPLE_CLASS_BOILERPLATE(OmpBeginAssumesDirective);
4464+
struct OmpAssumesDirective {
4465+
TUPLE_CLASS_BOILERPLATE(OmpAssumesDirective);
44664466
std::tuple<Verbatim, OmpClauseList> t;
44674467
CharBlock source;
44684468
};
@@ -4474,14 +4474,14 @@ struct OmpEndAssumesDirective {
44744474

44754475
// structured-block
44764476
// ...
4477-
struct OpenMPAssumesPartConstruct {
4478-
WRAPPER_CLASS_BOILERPLATE(OpenMPAssumesPartConstruct, Block);
4477+
struct OmpAssumesPartConstruct {
4478+
WRAPPER_CLASS_BOILERPLATE(OmpAssumesPartConstruct, Block);
44794479
CharBlock source;
44804480
};
44814481

4482-
struct OpenMPBeginAssumesConstruct {
4483-
TUPLE_CLASS_BOILERPLATE(OpenMPBeginAssumesConstruct);
4484-
std::tuple<OmpBeginAssumesDirective, OpenMPAssumesPartConstruct,
4482+
struct OpenMPAssumesConstruct {
4483+
TUPLE_CLASS_BOILERPLATE(OpenMPAssumesConstruct);
4484+
std::tuple<OmpAssumesDirective, OmpAssumesPartConstruct,
44854485
OmpEndAssumesDirective>
44864486
t;
44874487
CharBlock source;
@@ -4620,7 +4620,8 @@ struct OpenMPDeclarativeAllocate {
46204620
struct OpenMPDeclarativeConstruct {
46214621
UNION_CLASS_BOILERPLATE(OpenMPDeclarativeConstruct);
46224622
CharBlock source;
4623-
std::variant<OpenMPDeclarativeAllocate, OpenMPAssumesConstruct, OpenMPDeclareMapperConstruct,
4623+
std::variant<OpenMPDeclarativeAllocate, OpenMPAssumesConstruct, OpenMPDeclarativeAssume,
4624+
OpenMPDeclareMapperConstruct,
46244625
OpenMPDeclareReductionConstruct, OpenMPDeclareSimdConstruct,
46254626
OpenMPDeclareTargetConstruct, OpenMPThreadprivate,
46264627
OpenMPRequiresConstruct, OpenMPUtilityConstruct>
@@ -4910,7 +4911,7 @@ struct OpenMPConstruct {
49104911
OpenMPSectionConstruct, OpenMPLoopConstruct, OpenMPBlockConstruct,
49114912
OpenMPAtomicConstruct, OpenMPDeclarativeAllocate, OpenMPDispatchConstruct,
49124913
OpenMPUtilityConstruct, OpenMPExecutableAllocate,
4913-
OpenMPAllocatorsConstruct, OpenMPAssumeConstruct, OpenMPBeginAssumesConstruct, OpenMPCriticalConstruct>
4914+
OpenMPAllocatorsConstruct, OpenMPAssumeConstruct, OpenMPCriticalConstruct>
49144915
u;
49154916
};
49164917

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3079,7 +3079,7 @@ genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
30793079
static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
30803080
semantics::SemanticsContext &semaCtx,
30813081
lower::pft::Evaluation &eval,
3082-
const parser::OpenMPAssumesConstruct &assumesConstruct) {
3082+
const parser::OpenMPDeclarativeAssumes &assumesConstruct) {
30833083
TODO(converter.getCurrentLocation(), "OpenMP ASSUMES declaration");
30843084
}
30853085

@@ -3390,13 +3390,13 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
33903390
TODO(clauseLocation, "OpenMP ASSUME construct");
33913391
}
33923392

3393-
static void
3394-
genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
3395-
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
3396-
const parser::OpenMPBeginAssumesConstruct &beginAssumesConstruct) {
3393+
static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,
3394+
semantics::SemanticsContext &semaCtx,
3395+
lower::pft::Evaluation &eval,
3396+
const parser::OpenMPAssumesConstruct &assumesConstruct) {
33973397
mlir::Location clauseLocation =
3398-
converter.genLocation(beginAssumesConstruct.source);
3399-
TODO(clauseLocation, "OpenMP BEGIN ASSUMES construct");
3398+
converter.genLocation(assumesConstruct.source);
3399+
TODO(clauseLocation, "OpenMP ASSUMES construct");
34003400
}
34013401

34023402
static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable,

flang/lib/Parser/openmp-parsers.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,14 +1296,14 @@ TYPE_PARSER(
12961296
lookAhead(endOmpLine / !statement(allocateStmt)))
12971297

12981298
// Assumes Construct
1299-
TYPE_PARSER(sourced(construct<OpenMPAssumesConstruct>(
1299+
TYPE_PARSER(sourced(construct<OpenMPDeclarativeAssumes>(
13001300
verbatim("ASSUMES"_tok), Parser<OmpClauseList>{})))
13011301

13021302
// Declarative constructs
13031303
TYPE_PARSER(startOmpLine >>
13041304
withMessage("expected OpenMP construct"_err_en_US,
13051305
sourced(construct<OpenMPDeclarativeConstruct>(
1306-
Parser<OpenMPAssumesConstruct>{}) ||
1306+
Parser<OpenMPDeclarativeAssumes>{}) ||
13071307
construct<OpenMPDeclarativeConstruct>(
13081308
Parser<OpenMPDeclareReductionConstruct>{}) ||
13091309
construct<OpenMPDeclarativeConstruct>(
@@ -1327,17 +1327,17 @@ TYPE_PARSER(sourced(construct<OpenMPAssumeConstruct>(
13271327
verbatim("ASSUME"_tok), Parser<OmpClauseList>{}) /
13281328
endOmpLine))
13291329

1330-
TYPE_PARSER(sourced(construct<OmpBeginAssumesDirective>(
1331-
"BEGIN"_tok >> verbatim("ASSUMES"_tok), Parser<OmpClauseList>{})))
1330+
TYPE_PARSER(sourced(construct<OmpAssumesDirective>(
1331+
verbatim("ASSUMES"_tok), Parser<OmpClauseList>{})))
13321332

13331333
TYPE_PARSER(sourced(construct<OmpEndAssumesDirective>(
13341334
verbatim(startOmpLine >> "END ASSUMES"_tok))))
13351335

1336-
TYPE_PARSER(construct<OpenMPAssumesPartConstruct>(block))
1336+
TYPE_PARSER(construct<OmpAssumesPartConstruct>(block))
13371337

1338-
TYPE_PARSER(sourced(construct<OpenMPBeginAssumesConstruct>(
1339-
Parser<OmpBeginAssumesDirective>{} / endOmpLine,
1340-
Parser<OpenMPAssumesPartConstruct>{},
1338+
TYPE_PARSER(sourced(construct<OpenMPAssumesConstruct>(
1339+
Parser<OmpAssumesDirective>{} / endOmpLine,
1340+
Parser<OmpAssumesPartConstruct>{},
13411341
Parser<OmpEndAssumesDirective>{} / endOmpLine)))
13421342

13431343
// Block Construct
@@ -1387,8 +1387,7 @@ TYPE_CONTEXT_PARSER("OpenMP construct"_en_US,
13871387
construct<OpenMPConstruct>(Parser<OpenMPExecutableAllocate>{}),
13881388
construct<OpenMPConstruct>(Parser<OpenMPAllocatorsConstruct>{}),
13891389
construct<OpenMPConstruct>(Parser<OpenMPDeclarativeAllocate>{}),
1390-
construct<OpenMPConstruct>(
1391-
Parser<OpenMPBeginAssumesConstruct>{}),
1390+
construct<OpenMPConstruct>(Parser<OpenMPAssumesConstruct>{}),
13921391
construct<OpenMPConstruct>(Parser<OpenMPAssumeConstruct>{}),
13931392
construct<OpenMPConstruct>(Parser<OpenMPCriticalConstruct>{}))))
13941393

flang/lib/Parser/unparse.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,9 +2648,9 @@ class UnparseVisitor {
26482648
Put("\n");
26492649
EndOpenMP();
26502650
}
2651-
void Unparse(const OmpBeginAssumesDirective &x) {
2651+
void Unparse(const OmpAssumesDirective &x) {
26522652
BeginOpenMP();
2653-
Word("!$OMP BEGIN ASSUMES");
2653+
Word("!$OMP ASSUMES");
26542654
Walk(std::get<OmpClauseList>(x.t), ", ");
26552655
Put("\n");
26562656
EndOpenMP();
@@ -2718,6 +2718,12 @@ class UnparseVisitor {
27182718
Put("\n");
27192719
EndOpenMP();
27202720
}
2721+
bool Pre(const OpenMPDeclarativeAssumes &x) {
2722+
Word("!$OMP ASSUMES ");
2723+
Walk(std::get<OmpClauseList>(x.t));
2724+
Put("\n");
2725+
EndOpenMP();
2726+
}
27212727
void Unparse(const OpenMPDeclareMapperConstruct &z) {
27222728
BeginOpenMP();
27232729
Word("!$OMP DECLARE MAPPER (");

flang/lib/Semantics/check-omp-structure.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1260,19 +1260,19 @@ void OmpStructureChecker::Leave(const parser::OpenMPAssumeConstruct &) {
12601260
dirContext_.pop_back();
12611261
}
12621262

1263-
void OmpStructureChecker::Enter(const parser::OpenMPAssumesConstruct &x) {
1263+
void OmpStructureChecker::Enter(const parser::OpenMPDeclarativeAssumes &x) {
12641264
PushContextAndClauseSets(x.source, llvm::omp::Directive::OMPD_assumes);
12651265
}
12661266

1267-
void OmpStructureChecker::Leave(const parser::OpenMPAssumesConstruct &) {
1267+
void OmpStructureChecker::Leave(const parser::OpenMPDeclarativeAssumes &) {
12681268
dirContext_.pop_back();
12691269
}
12701270

1271-
void OmpStructureChecker::Enter(const parser::OpenMPBeginAssumesConstruct &x) {
1271+
void OmpStructureChecker::Enter(const parser::OpenMPAssumesConstruct &x) {
12721272
PushContextAndClauseSets(x.source, llvm::omp::Directive::OMPD_assumes);
12731273
}
12741274

1275-
void OmpStructureChecker::Leave(const parser::OpenMPBeginAssumesConstruct &) {
1275+
void OmpStructureChecker::Leave(const parser::OpenMPAssumesConstruct &) {
12761276
dirContext_.pop_back();
12771277
}
12781278

flang/lib/Semantics/check-omp-structure.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ class OmpStructureChecker
8383

8484
void Enter(const parser::OpenMPAssumeConstruct &);
8585
void Leave(const parser::OpenMPAssumeConstruct &);
86+
void Enter(const parser::OpenMPDeclarativeAssumes &);
87+
void Leave(const parser::OpenMPDeclarativeAssumes &);
8688
void Enter(const parser::OpenMPAssumesConstruct &);
8789
void Leave(const parser::OpenMPAssumesConstruct &);
88-
void Enter(const parser::OpenMPBeginAssumesConstruct &);
89-
void Leave(const parser::OpenMPBeginAssumesConstruct &);
9090
void Enter(const parser::OpenMPBlockConstruct &);
9191
void Leave(const parser::OpenMPBlockConstruct &);
9292
void Leave(const parser::OmpBeginBlockDirective &);
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -fopenmp-version=51 -o - %s 2>&1 | FileCheck %s
22

3-
! CHECK: not yet implemented: OpenMP ASSUMES declaration
3+
! CHECK: not yet implemented: OpenMP ASSUMES construct
44
program p
5-
!$omp assumes no_openmp
65
integer r
6+
r = 1
7+
!$omp assumes no_parallelism
78
print *,r
9+
!$omp end assumes
810
end program p
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -fopenmp-version=51 -o - %s 2>&1 | FileCheck %s
22

3-
! CHECK: not yet implemented: OpenMP BEGIN ASSUMES construct
3+
! CHECK: not yet implemented: OpenMP ASSUMES declaration
44
program p
5+
!$omp assumes no_openmp
56
integer r
6-
!$omp begin assumes no_parallelism
77
print *,r
8-
!$omp end assumes
98
end program p

flang/test/Parser/OpenMP/assumption.f90

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,18 @@ end subroutine sub1
3131

3232
subroutine sub2
3333
integer :: r
34-
!CHECK !$OMP BEGIN ASSUMES NO_OPENMP
35-
!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPBeginAssumesConstruct
36-
!PARSE-TREE: OmpBeginAssumesDirective
34+
integer :: v
35+
!CHECK !$OMP ASSUMES NO_OPENMP
36+
!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPAssumesConstruct
37+
!PARSE-TREE: OmpAssumesDirective
3738
!PARSE-TREE: Verbatim
3839
!PARSE-TREE: OmpClauseList -> OmpClause -> NoOpenmp
39-
!PARSE-TREE: OpenMPAssumesPartConstruct -> Block
40+
!PARSE-TREE: OmpAssumesPartConstruct -> Block
4041
!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> ActionStmt -> AssignmentStmt
4142
!PARSE-TREE: Expr -> Add
42-
!PARSE-TREE: OmpEndAssumesDirective
43-
!$omp begin assumes no_openmp
43+
!PARSE-TREE: OmpEndAssumesDirective
44+
v = 87
45+
!$omp assumes no_openmp
4446
r = r + 1
4547
!CHECK !$OMP END ASSUMES
4648
!$omp end assumes
@@ -49,7 +51,7 @@ end subroutine sub2
4951
program p
5052
!CHECK !$OMP ASSUMES NO_OPENMP
5153
!PARSE-TREE: SpecificationPart
52-
!PARSE-TREE: OpenMPDeclarativeConstruct -> OpenMPAssumesConstruct
54+
!PARSE-TREE: OpenMPDeclarativeConstruct -> OpenMPDeclarativeAssumes
5355
!PARSE-TREE: Verbatim
5456
!PARSE-TREE: OmpClauseList -> OmpClause -> NoOpenmp
5557
!$omp assumes no_openmp

0 commit comments

Comments
 (0)