xref: /llvm-project/flang/test/Semantics/OpenMP/nested-master.f90 (revision e67e09a77ea1e4802c0f6bc0409c9f5e9d1fae9a)
13323a4bdSKiran Chandramohan! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp
23323a4bdSKiran Chandramohan! OpenMP Version 4.5
33323a4bdSKiran Chandramohan! Various checks with the nesting of MASTER construct
43323a4bdSKiran Chandramohan
53323a4bdSKiran Chandramohanprogram omp_nest_master
63323a4bdSKiran Chandramohan  integer i, k, j
73323a4bdSKiran Chandramohan  k = 0;
83323a4bdSKiran Chandramohan
93323a4bdSKiran Chandramohan  !$omp do
103323a4bdSKiran Chandramohan  do i = 1, 10
113323a4bdSKiran Chandramohan    k = k + 1
12092a819eSKiran Chandramohan    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
133323a4bdSKiran Chandramohan    !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
143323a4bdSKiran Chandramohan    !$omp master
153323a4bdSKiran Chandramohan    j = j -1
163323a4bdSKiran Chandramohan    !$omp end master
173323a4bdSKiran Chandramohan  end do
183323a4bdSKiran Chandramohan
193323a4bdSKiran Chandramohan  !$omp sections
20092a819eSKiran Chandramohan  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
213323a4bdSKiran Chandramohan  !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
223323a4bdSKiran Chandramohan    !$omp master
233323a4bdSKiran Chandramohan    do i = 1, 10
243323a4bdSKiran Chandramohan      k = k + 1
253323a4bdSKiran Chandramohan    end do
263323a4bdSKiran Chandramohan    !$omp end master
273323a4bdSKiran Chandramohan  !$omp end sections
283323a4bdSKiran Chandramohan
293323a4bdSKiran Chandramohan  !$omp single
30092a819eSKiran Chandramohan  !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
313323a4bdSKiran Chandramohan  !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
323323a4bdSKiran Chandramohan    !$omp master
333323a4bdSKiran Chandramohan    do i = 1, 10
343323a4bdSKiran Chandramohan      k = k + 1
353323a4bdSKiran Chandramohan    end do
363323a4bdSKiran Chandramohan    !$omp end master
373323a4bdSKiran Chandramohan  !$omp end single
383323a4bdSKiran Chandramohan
393323a4bdSKiran Chandramohan
403323a4bdSKiran Chandramohan
413323a4bdSKiran Chandramohan  !$omp task
423323a4bdSKiran Chandramohan  do i = 1, 10
433323a4bdSKiran Chandramohan    k = k + 1
44092a819eSKiran Chandramohan    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
453323a4bdSKiran Chandramohan    !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
463323a4bdSKiran Chandramohan    !$omp master
473323a4bdSKiran Chandramohan    j = j -1
483323a4bdSKiran Chandramohan    !$omp end master
493323a4bdSKiran Chandramohan  end do
503323a4bdSKiran Chandramohan  !$omp end task
513323a4bdSKiran Chandramohan
523323a4bdSKiran Chandramohan  !$omp taskloop
533323a4bdSKiran Chandramohan  do i = 1, 10
543323a4bdSKiran Chandramohan    k = k + 1
55092a819eSKiran Chandramohan    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
563323a4bdSKiran Chandramohan    !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
573323a4bdSKiran Chandramohan    !$omp master
583323a4bdSKiran Chandramohan    j = j -1
593323a4bdSKiran Chandramohan    !$omp end master
603323a4bdSKiran Chandramohan  end do
613323a4bdSKiran Chandramohan  !$omp end taskloop
623323a4bdSKiran Chandramohan
633323a4bdSKiran Chandramohan  !$omp target parallel do simd
643323a4bdSKiran Chandramohan  do i = 1, 10
653323a4bdSKiran Chandramohan    k = k + 1
66092a819eSKiran Chandramohan    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
67*e67e09a7SAnchu Rajendran S    !ERROR: The only OpenMP constructs that can be encountered during execution of a 'SIMD' region are the `ATOMIC` construct, the `LOOP` construct, the `SIMD` construct, the `SCAN` construct and the `ORDERED` construct with the `SIMD` clause.
683323a4bdSKiran Chandramohan    !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
693323a4bdSKiran Chandramohan    !$omp master
703323a4bdSKiran Chandramohan    j = j -1
713323a4bdSKiran Chandramohan    !$omp end master
723323a4bdSKiran Chandramohan  end do
733323a4bdSKiran Chandramohan  !$omp end target parallel do simd
743323a4bdSKiran Chandramohan
753323a4bdSKiran Chandramohan  !$omp critical
763323a4bdSKiran Chandramohan  do i = 1, 10
773323a4bdSKiran Chandramohan    k = k + 1
78092a819eSKiran Chandramohan    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
793323a4bdSKiran Chandramohan    !$omp master
803323a4bdSKiran Chandramohan    j = j -1
813323a4bdSKiran Chandramohan    !$omp end master
823323a4bdSKiran Chandramohan  end do
833323a4bdSKiran Chandramohan  !$omp end critical
843323a4bdSKiran Chandramohan
853323a4bdSKiran Chandramohan  !$omp ordered
863323a4bdSKiran Chandramohan  do i = 1, 10
873323a4bdSKiran Chandramohan    k = k + 1
88092a819eSKiran Chandramohan    !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
893323a4bdSKiran Chandramohan    !$omp master
903323a4bdSKiran Chandramohan    j = j -1
913323a4bdSKiran Chandramohan    !$omp end master
923323a4bdSKiran Chandramohan  end do
933323a4bdSKiran Chandramohan  !$omp end ordered
943323a4bdSKiran Chandramohan
953323a4bdSKiran Chandramohan  !$omp ordered
963323a4bdSKiran Chandramohan  do i = 1, 10
973323a4bdSKiran Chandramohan    !ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
983323a4bdSKiran Chandramohan    !$omp teams
993323a4bdSKiran Chandramohan    !$omp distribute
1003323a4bdSKiran Chandramohan    do k =1, 10
1013323a4bdSKiran Chandramohan      print *, "hello"
102092a819eSKiran Chandramohan      !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
1033323a4bdSKiran Chandramohan      !$omp master
1043323a4bdSKiran Chandramohan      j = j -1
1053323a4bdSKiran Chandramohan      !$omp end master
1063323a4bdSKiran Chandramohan    end do
1073323a4bdSKiran Chandramohan    !$omp end distribute
1083323a4bdSKiran Chandramohan    !$omp end teams
1093323a4bdSKiran Chandramohan  end do
1103323a4bdSKiran Chandramohan  !$omp end ordered
1113323a4bdSKiran Chandramohan
1123323a4bdSKiran Chandramohan  !$omp critical
1133323a4bdSKiran Chandramohan  do i = 1, 10
1143323a4bdSKiran Chandramohan    !ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
1153323a4bdSKiran Chandramohan    !$omp teams
1163323a4bdSKiran Chandramohan    !$omp distribute
1173323a4bdSKiran Chandramohan    do k =1, 10
1183323a4bdSKiran Chandramohan      print *, "hello"
119092a819eSKiran Chandramohan      !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
1203323a4bdSKiran Chandramohan      !$omp master
1213323a4bdSKiran Chandramohan      j = j -1
1223323a4bdSKiran Chandramohan      !$omp end master
1233323a4bdSKiran Chandramohan    end do
1243323a4bdSKiran Chandramohan    !$omp end distribute
1253323a4bdSKiran Chandramohan    !$omp end teams
1263323a4bdSKiran Chandramohan  end do
1273323a4bdSKiran Chandramohan  !$omp end critical
1283323a4bdSKiran Chandramohan
1293323a4bdSKiran Chandramohan  !$omp taskloop
1303323a4bdSKiran Chandramohan  do i = 1, 10
1313323a4bdSKiran Chandramohan    !ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
1323323a4bdSKiran Chandramohan    !$omp teams
1333323a4bdSKiran Chandramohan    !$omp distribute
1343323a4bdSKiran Chandramohan    do k =1, 10
1353323a4bdSKiran Chandramohan      print *, "hello"
136092a819eSKiran Chandramohan      !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
1373323a4bdSKiran Chandramohan      !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
1383323a4bdSKiran Chandramohan      !$omp master
1393323a4bdSKiran Chandramohan      j = j -1
1403323a4bdSKiran Chandramohan      !$omp end master
1413323a4bdSKiran Chandramohan    end do
1423323a4bdSKiran Chandramohan    !$omp end distribute
1433323a4bdSKiran Chandramohan    !$omp end teams
1443323a4bdSKiran Chandramohan  end do
1453323a4bdSKiran Chandramohan  !$omp end taskloop
1463323a4bdSKiran Chandramohan
1473323a4bdSKiran Chandramohan  !$omp task
1483323a4bdSKiran Chandramohan  do i = 1, 10
1493323a4bdSKiran Chandramohan    !ERROR: TEAMS region can only be strictly nested within the implicit parallel region or TARGET region
1503323a4bdSKiran Chandramohan    !$omp teams
1513323a4bdSKiran Chandramohan    !$omp distribute
1523323a4bdSKiran Chandramohan    do k =1, 10
1533323a4bdSKiran Chandramohan      print *, "hello"
154092a819eSKiran Chandramohan      !WARNING: OpenMP directive MASTER has been deprecated, please use MASKED instead.
1553323a4bdSKiran Chandramohan      !ERROR: `MASTER` region may not be closely nested inside of `WORKSHARING`, `LOOP`, `TASK`, `TASKLOOP`, or `ATOMIC` region.
1563323a4bdSKiran Chandramohan      !$omp master
1573323a4bdSKiran Chandramohan      j = j -1
1583323a4bdSKiran Chandramohan      !$omp end master
1593323a4bdSKiran Chandramohan    end do
1603323a4bdSKiran Chandramohan    !$omp end distribute
1613323a4bdSKiran Chandramohan    !$omp end teams
1623323a4bdSKiran Chandramohan  end do
1633323a4bdSKiran Chandramohan  !$omp end task
1643323a4bdSKiran Chandramohan
1653323a4bdSKiran Chandramohanend program omp_nest_master
166