xref: /llvm-project/flang/test/Semantics/OpenMP/declare-target02.f90 (revision 00ab44ee66dbcf0d32819dbc6e4eefd1b7c48dfa)
1*00ab44eeSKrzysztof Parzyszek! RUN: %python %S/../test_errors.py %s %flang_fc1 -fopenmp -fopenmp-version=52
23323a4bdSKiran Chandramohan! OpenMP Version 5.1
33323a4bdSKiran Chandramohan! Check OpenMP construct validity for the following directives:
43323a4bdSKiran Chandramohan! 2.14.7 Declare Target Directive
53323a4bdSKiran Chandramohan
63323a4bdSKiran Chandramohanprogram declare_target02
73323a4bdSKiran Chandramohan  integer :: arr1(10), arr1_to(10), arr1_link(10)
83323a4bdSKiran Chandramohan  common /blk1/ a1, a1_to, a1_link
93323a4bdSKiran Chandramohan  real, save :: eq_a, eq_b, eq_c, eq_d
103323a4bdSKiran Chandramohan
113323a4bdSKiran Chandramohan
123323a4bdSKiran Chandramohan  !$omp declare target (arr1)
133323a4bdSKiran Chandramohan
143323a4bdSKiran Chandramohan  !$omp declare target (blk1)
153323a4bdSKiran Chandramohan
163323a4bdSKiran Chandramohan  !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
173323a4bdSKiran Chandramohan  !$omp declare target (a1)
183323a4bdSKiran Chandramohan
198840eb3fSShraiysh  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
203323a4bdSKiran Chandramohan  !$omp declare target to (arr1_to)
213323a4bdSKiran Chandramohan
228840eb3fSShraiysh  !$omp declare target enter (arr1_to)
238840eb3fSShraiysh
248840eb3fSShraiysh  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
253323a4bdSKiran Chandramohan  !$omp declare target to (blk1_to)
263323a4bdSKiran Chandramohan
278840eb3fSShraiysh  !$omp declare target enter (blk1_to)
288840eb3fSShraiysh
298840eb3fSShraiysh  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
303323a4bdSKiran Chandramohan  !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
313323a4bdSKiran Chandramohan  !$omp declare target to (a1_to)
323323a4bdSKiran Chandramohan
338840eb3fSShraiysh  !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
348840eb3fSShraiysh  !$omp declare target enter (a1_to)
358840eb3fSShraiysh
363323a4bdSKiran Chandramohan  !$omp declare target link (arr1_link)
373323a4bdSKiran Chandramohan
383323a4bdSKiran Chandramohan  !$omp declare target link (blk1_link)
393323a4bdSKiran Chandramohan
403323a4bdSKiran Chandramohan  !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
413323a4bdSKiran Chandramohan  !$omp declare target link (a1_link)
423323a4bdSKiran Chandramohan
433323a4bdSKiran Chandramohan  equivalence(eq_a, eq_b)
443323a4bdSKiran Chandramohan  !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
453323a4bdSKiran Chandramohan  !$omp declare target (eq_a)
463323a4bdSKiran Chandramohan
478840eb3fSShraiysh  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
483323a4bdSKiran Chandramohan  !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
493323a4bdSKiran Chandramohan  !$omp declare target to (eq_a)
503323a4bdSKiran Chandramohan
513323a4bdSKiran Chandramohan  !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
528840eb3fSShraiysh  !$omp declare target enter (eq_a)
538840eb3fSShraiysh
548840eb3fSShraiysh  !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
553323a4bdSKiran Chandramohan  !$omp declare target link (eq_b)
563323a4bdSKiran Chandramohan
573323a4bdSKiran Chandramohan  !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
583323a4bdSKiran Chandramohan  !$omp declare target (eq_c)
593323a4bdSKiran Chandramohan
608840eb3fSShraiysh  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
613323a4bdSKiran Chandramohan  !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
623323a4bdSKiran Chandramohan  !$omp declare target to (eq_c)
633323a4bdSKiran Chandramohan
643323a4bdSKiran Chandramohan  !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
658840eb3fSShraiysh  !$omp declare target enter (eq_c)
668840eb3fSShraiysh
678840eb3fSShraiysh  !ERROR: A variable in a DECLARE TARGET directive cannot appear in an EQUIVALENCE statement
683323a4bdSKiran Chandramohan  !$omp declare target link (eq_d)
693323a4bdSKiran Chandramohan  equivalence(eq_c, eq_d)
703323a4bdSKiran Chandramohan
713323a4bdSKiran Chandramohancontains
723323a4bdSKiran Chandramohan  subroutine func()
733323a4bdSKiran Chandramohan    integer :: arr2(10), arr2_to(10), arr2_link(10)
743323a4bdSKiran Chandramohan    integer, save :: arr3(10), arr3_to(10), arr3_link(10)
753323a4bdSKiran Chandramohan    common /blk2/ a2, a2_to, a2_link
763323a4bdSKiran Chandramohan    common /blk3/ a3, a3_to, a3_link
773323a4bdSKiran Chandramohan    save /blk3/
783323a4bdSKiran Chandramohan
793323a4bdSKiran Chandramohan    !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
803323a4bdSKiran Chandramohan    !$omp declare target (arr2)
813323a4bdSKiran Chandramohan
823323a4bdSKiran Chandramohan    !$omp declare target (arr3)
833323a4bdSKiran Chandramohan
843323a4bdSKiran Chandramohan    !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
853323a4bdSKiran Chandramohan    !$omp declare target (a2)
863323a4bdSKiran Chandramohan
873323a4bdSKiran Chandramohan    !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
883323a4bdSKiran Chandramohan    !$omp declare target (a3)
893323a4bdSKiran Chandramohan
908840eb3fSShraiysh    !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
913323a4bdSKiran Chandramohan    !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
923323a4bdSKiran Chandramohan    !$omp declare target to (arr2_to)
933323a4bdSKiran Chandramohan
948840eb3fSShraiysh    !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
958840eb3fSShraiysh    !$omp declare target enter (arr2_to)
968840eb3fSShraiysh
978840eb3fSShraiysh    !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
983323a4bdSKiran Chandramohan    !$omp declare target to (arr3_to)
993323a4bdSKiran Chandramohan
1008840eb3fSShraiysh    !$omp declare target enter (arr3_to)
1018840eb3fSShraiysh
1028840eb3fSShraiysh    !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
1033323a4bdSKiran Chandramohan    !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
1043323a4bdSKiran Chandramohan    !$omp declare target to (a2_to)
1053323a4bdSKiran Chandramohan
1063323a4bdSKiran Chandramohan    !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
1078840eb3fSShraiysh    !$omp declare target enter (a2_to)
1088840eb3fSShraiysh
1098840eb3fSShraiysh    !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
1108840eb3fSShraiysh    !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
1113323a4bdSKiran Chandramohan    !$omp declare target to (a3_to)
1123323a4bdSKiran Chandramohan
1138840eb3fSShraiysh    !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
1148840eb3fSShraiysh    !$omp declare target enter (a3_to)
1158840eb3fSShraiysh
1163323a4bdSKiran Chandramohan    !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
1173323a4bdSKiran Chandramohan    !$omp declare target link (arr2_link)
1183323a4bdSKiran Chandramohan
1193323a4bdSKiran Chandramohan    !$omp declare target link (arr3_link)
1203323a4bdSKiran Chandramohan
1213323a4bdSKiran Chandramohan    !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
1223323a4bdSKiran Chandramohan    !$omp declare target link (a2_link)
1233323a4bdSKiran Chandramohan
1243323a4bdSKiran Chandramohan    !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
1253323a4bdSKiran Chandramohan    !$omp declare target link (a3_link)
1263323a4bdSKiran Chandramohan  end
1273323a4bdSKiran Chandramohanend
1283323a4bdSKiran Chandramohan
1293323a4bdSKiran Chandramohanmodule mod4
1303323a4bdSKiran Chandramohan  integer :: arr4(10), arr4_to(10), arr4_link(10)
1313323a4bdSKiran Chandramohan  common /blk4/ a4, a4_to, a4_link
1323323a4bdSKiran Chandramohan
1333323a4bdSKiran Chandramohan  !$omp declare target (arr4)
1343323a4bdSKiran Chandramohan
1353323a4bdSKiran Chandramohan  !$omp declare target (blk4)
1363323a4bdSKiran Chandramohan
1373323a4bdSKiran Chandramohan  !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
1383323a4bdSKiran Chandramohan  !$omp declare target (a4)
1393323a4bdSKiran Chandramohan
1408840eb3fSShraiysh  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
1413323a4bdSKiran Chandramohan  !$omp declare target to (arr4_to)
1423323a4bdSKiran Chandramohan
1438840eb3fSShraiysh  !$omp declare target enter (arr4_to)
1447ff8094aSShraiysh
1458840eb3fSShraiysh  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
1468840eb3fSShraiysh  !$omp declare target to (blk4_to)
1478840eb3fSShraiysh  !$omp declare target enter (blk4_to)
1488840eb3fSShraiysh
1498840eb3fSShraiysh  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
1503323a4bdSKiran Chandramohan  !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
1513323a4bdSKiran Chandramohan  !$omp declare target to (a4_to)
1523323a4bdSKiran Chandramohan
1538840eb3fSShraiysh  !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
1548840eb3fSShraiysh  !$omp declare target enter (a4_to)
1558840eb3fSShraiysh
1563323a4bdSKiran Chandramohan  !$omp declare target link (arr4_link)
1573323a4bdSKiran Chandramohan
1583323a4bdSKiran Chandramohan  !$omp declare target link (blk4_link)
1593323a4bdSKiran Chandramohan
1603323a4bdSKiran Chandramohan  !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
1613323a4bdSKiran Chandramohan  !$omp declare target link (a4_link)
1623323a4bdSKiran Chandramohanend
1633323a4bdSKiran Chandramohan
1643323a4bdSKiran Chandramohansubroutine func5()
1653323a4bdSKiran Chandramohan  integer :: arr5(10), arr5_to(10), arr5_link(10)
1663323a4bdSKiran Chandramohan  common /blk5/ a5, a5_to, a5_link
1673323a4bdSKiran Chandramohan
1683323a4bdSKiran Chandramohan  !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
1693323a4bdSKiran Chandramohan  !$omp declare target (arr5)
1703323a4bdSKiran Chandramohan
1713323a4bdSKiran Chandramohan  !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
1723323a4bdSKiran Chandramohan  !$omp declare target (blk5)
1733323a4bdSKiran Chandramohan
1743323a4bdSKiran Chandramohan  !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
1753323a4bdSKiran Chandramohan  !$omp declare target (a5)
1763323a4bdSKiran Chandramohan
1778840eb3fSShraiysh  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
1783323a4bdSKiran Chandramohan  !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
1793323a4bdSKiran Chandramohan  !$omp declare target to (arr5_to)
1803323a4bdSKiran Chandramohan
1813323a4bdSKiran Chandramohan  !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
1828840eb3fSShraiysh  !$omp declare target enter (arr5_to)
1838840eb3fSShraiysh
1848840eb3fSShraiysh  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
1858840eb3fSShraiysh  !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
1863323a4bdSKiran Chandramohan  !$omp declare target to (blk5_to)
1873323a4bdSKiran Chandramohan
1888840eb3fSShraiysh  !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
1898840eb3fSShraiysh  !$omp declare target enter (blk5_to)
1908840eb3fSShraiysh
1918840eb3fSShraiysh  !WARNING: The usage of TO clause on DECLARE TARGET directive has been deprecated. Use ENTER clause instead.
1923323a4bdSKiran Chandramohan  !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
1933323a4bdSKiran Chandramohan  !$omp declare target to (a5_to)
1943323a4bdSKiran Chandramohan
1958840eb3fSShraiysh  !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
1968840eb3fSShraiysh  !$omp declare target enter (a5_to)
1978840eb3fSShraiysh
1983323a4bdSKiran Chandramohan  !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
1993323a4bdSKiran Chandramohan  !$omp declare target link (arr5_link)
2003323a4bdSKiran Chandramohan
2013323a4bdSKiran Chandramohan  !ERROR: A variable that appears in a DECLARE TARGET directive must be declared in the scope of a module or have the SAVE attribute, either explicitly or implicitly
2023323a4bdSKiran Chandramohan  !$omp declare target link (blk5_link)
2033323a4bdSKiran Chandramohan
2043323a4bdSKiran Chandramohan  !ERROR: A variable in a DECLARE TARGET directive cannot be an element of a common block
2053323a4bdSKiran Chandramohan  !$omp declare target link (a5_link)
2063323a4bdSKiran Chandramohanend
207