brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.3 KiB · d953287 Raw
149 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic2subroutine forall13  real :: a(9)4  !ERROR: 'i' is already declared in this scoping unit5  !ERROR: Cannot redefine FORALL variable 'i'6  forall (i=1:8, i=1:9)  a(i) = i7  !ERROR: 'i' is already declared in this scoping unit8  !ERROR: Cannot redefine FORALL variable 'i'9  forall (i=1:8, i=1:9)10    a(i) = i11  end forall12  forall (j=1:8)13    !PORTABILITY: Index variable 'j' should not also be an index in an enclosing FORALL or DO CONCURRENT [-Wodd-index-variable-restrictions]14    forall (j=1:9)15    end forall16  end forall17end18 19subroutine forall220  integer, pointer :: a(:)21  integer, target :: b(10,10)22  forall (i=1:10)23    !ERROR: Impure procedure 'f_impure' may not be referenced in a FORALL24    a(f_impure(i):) => b(i,:)25  end forall26  !ERROR: FORALL mask expression may not reference impure procedure 'f_impure'27  forall (j=1:10, f_impure(1)>2)28  end forall29contains30  impure integer function f_impure(i)31    f_impure = i32  end33end34 35subroutine forall336  real :: x37  forall(i=1:10)38    !ERROR: Cannot redefine FORALL variable 'i'39    i = 140  end forall41  forall(i=1:10)42    forall(j=1:10)43      !ERROR: Cannot redefine FORALL variable 'i'44      !WARNING: FORALL index variable 'j' not used on left-hand side of assignment [-Wunused-forall-index]45      i = 146    end forall47  end forall48  !ERROR: Cannot redefine FORALL variable 'i'49  forall(i=1:10) i = 150end51 52subroutine forall453  integer, parameter :: zero = 054  integer :: a(10)55 56  !ERROR: FORALL limit expression may not reference index variable 'i'57  forall(i=1:i)58    a(i) = i59  end forall60  !ERROR: FORALL step expression may not reference index variable 'i'61  forall(i=1:10:i)62    a(i) = i63  end forall64  !ERROR: FORALL step expression may not be zero65  forall(i=1:10:zero)66    a(i) = i67  end forall68 69  !ERROR: FORALL limit expression may not reference index variable 'i'70  forall(i=1:i) a(i) = i71  !ERROR: FORALL step expression may not reference index variable 'i'72  forall(i=1:10:i) a(i) = i73  !ERROR: FORALL step expression may not be zero74  forall(i=1:10:zero) a(i) = i75end76 77subroutine forall578  real, target :: x(10), y(10)79  forall(i=1:10)80    x(i) = y(i)81  end forall82  forall(i=1:10)83    !WARNING: FORALL index variable 'i' not used on left-hand side of assignment [-Wunused-forall-index]84    x = y85    forall(j=1:10)86      !WARNING: FORALL index variable 'j' not used on left-hand side of assignment [-Wunused-forall-index]87      x(i) = y(i)88      !WARNING: FORALL index variable 'i' not used on left-hand side of assignment [-Wunused-forall-index]89      x(j) = y(j)90    endforall91  endforall92  do concurrent(i=1:10)93    x = y94    !Odd rule from F'2023 19.4 p895    !PORTABILITY: Index variable 'i' should not also be an index in an enclosing FORALL or DO CONCURRENT [-Wodd-index-variable-restrictions]96    !WARNING: FORALL index variable 'i' not used on left-hand side of assignment [-Wunused-forall-index]97    forall(i=1:10) x = y98  end do99end100 101subroutine forall6102  type t103    real, pointer :: p104  end type105  type(t) :: a(10)106  real, target :: b(10)107  forall(i=1:10)108    a(i)%p => b(i)109    !WARNING: FORALL index variable 'i' not used on left-hand side of assignment [-Wunused-forall-index]110    a(1)%p => b(i)111  end forall112end113 114subroutine forall7(x)115  integer :: iarr(1)116  real :: a(10)117  class(*) :: x118  associate (j => iarr(1))119    !PORTABILITY: Index variable 'j' should be a scalar object or common block if it is present in the enclosing scope [-Wodd-index-variable-restrictions]120    forall (j=1:size(a))121      a(j) = a(j) + 1122    end forall123  end associate124  associate (j => iarr(1) + 1)125    !PORTABILITY: Index variable 'j' should be a scalar object or common block if it is present in the enclosing scope [-Wodd-index-variable-restrictions]126    forall (j=1:size(a))127      a(j) = a(j) + 1128    end forall129  end associate130  select type (j => x)131  type is (integer)132    !PORTABILITY: Index variable 'j' should be a scalar object or common block if it is present in the enclosing scope [-Wodd-index-variable-restrictions]133    forall (j=1:size(a))134      a(j) = a(j) + 1135    end forall136  end select137end subroutine138 139subroutine forall8(x)140  real :: x(10)141  real, external :: foo142  !ERROR: Impure procedure 'foo' may not be referenced in a FORALL143  forall(i=1:10) x(i) = foo() + i144  !OK145  associate(y => foo())146    forall (i=1:10) x(i) = y + i147  end associate148end subroutine149