brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.1 KiB · 0a1bdc3 Raw
200 lines · plain
1! RUN: %python %S/../test_errors.py %s %flang -fopenacc -pedantic2 3! Check OpenACC restruction in branch in and out of some construct4!5subroutine openacc_clause_validity6 7  implicit none8 9  integer :: i, j, k10  integer :: N = 25611  real(8) :: a(256)12 13  !$acc parallel14  !$acc loop15  do i = 1, N16    a(i) = 3.14d017    !ERROR: RETURN statement is not allowed in a PARALLEL construct18    return19  end do20  !$acc end parallel21 22  !$acc parallel loop23  do i = 1, N24    a(i) = 3.14d025    !ERROR: RETURN statement is not allowed in a PARALLEL LOOP construct26    return27  end do28 29  !$acc serial loop30  do i = 1, N31    a(i) = 3.14d032    !ERROR: RETURN statement is not allowed in a SERIAL LOOP construct33    return34  end do35 36  !$acc kernels loop37  do i = 1, N38    a(i) = 3.14d039    !ERROR: RETURN statement is not allowed in a KERNELS LOOP construct40    return41  end do42 43  !$acc parallel44  !$acc loop45  do i = 1, N46    a(i) = 3.14d047    if(i == N-1) THEN48      exit49    end if50  end do51  !$acc end parallel52 53  ! Exit branches out of parallel construct, not attached to an OpenACC parallel construct.54  name1: do k=1, N55  !$acc parallel56  !$acc loop57  outer: do i=1, N58    inner: do j=1, N59      ifname: if (j == 2) then60        ! These are allowed.61        exit62        exit inner63        exit outer64        !ERROR: EXIT to construct 'name1' outside of PARALLEL construct is not allowed65        exit name166        ! Exit to construct other than loops.67        exit ifname68      end if ifname69    end do inner70  end do outer71  !$acc end parallel72  end do name173 74  ! Exit branches out of parallel construct, attached to an OpenACC parallel construct.75  thisblk: BLOCK76    fortname: if (.true.) then77      !PORTABILITY: The construct name 'name1' should be distinct at the subprogram level [-Wbenign-name-clash]78      name1: do k = 1, N79        !$acc parallel80        !ERROR: EXIT to construct 'fortname' outside of PARALLEL construct is not allowed81        exit fortname82        !$acc loop83          do i = 1, N84            a(i) = 3.14d085            if(i == N-1) THEN86              !ERROR: EXIT to construct 'name1' outside of PARALLEL construct is not allowed87              exit name188            end if89          end do90 91          loop2: do i = 1, N92            a(i) = 3.33d093            !ERROR: EXIT to construct 'thisblk' outside of PARALLEL construct is not allowed94            exit thisblk95          end do loop296        !$acc end parallel97      end do name198    end if fortname99  end BLOCK thisblk100 101  !Exit branches inside OpenACC construct.102  !$acc parallel103  !$acc loop104  do i = 1, N105    a(i) = 3.14d0106    ifname: if (i == 2) then107      ! This is allowed.108      exit ifname109    end if ifname110  end do111  !$acc end parallel112 113  !$acc parallel114  !$acc loop115  do i = 1, N116    a(i) = 3.14d0117    if(i == N-1) THEN118      stop 999 ! no error119    end if120  end do121  !$acc end parallel122 123  !$acc kernels124  do i = 1, N125    a(i) = 3.14d0126    !ERROR: RETURN statement is not allowed in a KERNELS construct127    return128  end do129  !$acc end kernels130 131  !$acc kernels132  do i = 1, N133    a(i) = 3.14d0134    if(i == N-1) THEN135      exit136    end if137  end do138  !$acc end kernels139 140  !$acc kernels141  do i = 1, N142    a(i) = 3.14d0143    if(i == N-1) THEN144      stop 999 ! no error145    end if146  end do147  !$acc end kernels148 149  !$acc serial150  do i = 1, N151    a(i) = 3.14d0152    !ERROR: RETURN statement is not allowed in a SERIAL construct153    return154  end do155  !$acc end serial156 157  !$acc serial158  do i = 1, N159    a(i) = 3.14d0160    if(i == N-1) THEN161      exit162    end if163  end do164  !$acc end serial165 166  name2: do k=1, N167  !$acc serial168  do i = 1, N169    ifname: if (.true.) then170      print *, "LGTM"171    a(i) = 3.14d0172    if(i == N-1) THEN173        !ERROR: EXIT to construct 'name2' outside of SERIAL construct is not allowed174        exit name2175        exit ifname176      end if177    end if ifname178    end do179  !$acc end serial180  end do name2181 182  !$acc serial183  do i = 1, N184    a(i) = 3.14d0185    if(i == N-1) THEN186      stop 999 ! no error187    end if188  end do189  !$acc end serial190 191 192  !$acc data create(a)193 194  !ERROR: RETURN statement is not allowed in a DATA construct195  if (size(a) == 10) return196 197  !$acc end data198 199end subroutine openacc_clause_validity200