brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.9 KiB · b77e078 Raw
100 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Test DO loop semantics for constraint C1130 --3! The constraint states that "If the locality-spec DEFAULT ( NONE ) appears in a4! DO CONCURRENT statement; a variable that is a local or construct entity of a5! scope containing the DO CONCURRENT construct; and that appears in the block of6! the construct; shall have its locality explicitly specified by that7! statement."8 9module m10  real :: mvar11end module m12 13subroutine s1()14  use m15  integer :: i, ivar, jvar, kvar16  real :: x17 18  type point19    real :: x, y20  end type point21 22  type, extends(point) :: color_point23    integer :: color24  end type color_point25 26  type(point), target :: c27  class(point), pointer :: p_or_c28 29  p_or_c => c30 31  jvar = 532  33  ! References in this DO CONCURRENT are OK since there's no DEFAULT(NONE)34  ! locality-spec35  associate (avar => ivar)36    do concurrent (i = 1:2) shared(jvar)37      ivar = 338      ivar = ivar + i39      block40        real :: bvar41        avar = 442        x = 3.543        bvar = 3.5 + i44      end block45      jvar = 546      mvar = 3.547    end do48  end associate49  50  associate (avar => ivar)51!ERROR: DO CONCURRENT step expression may not be zero52    do concurrent (i = 1:2:0) default(none) shared(jvar) local(kvar)53!ERROR: Variable 'ivar' from an enclosing scope referenced in DO CONCURRENT with DEFAULT(NONE) must appear in a locality-spec54      ivar =  &55!ERROR: Variable 'ivar' from an enclosing scope referenced in DO CONCURRENT with DEFAULT(NONE) must appear in a locality-spec56        ivar + i57      block58        real :: bvar59!ERROR: Variable 'avar' from an enclosing scope referenced in DO CONCURRENT with DEFAULT(NONE) must appear in a locality-spec60        avar = 461!ERROR: Variable 'x' from an enclosing scope referenced in DO CONCURRENT with DEFAULT(NONE) must appear in a locality-spec62        x = 3.563        bvar = 3.5 + i ! OK, bvar's scope is within the DO CONCURRENT64      end block65      jvar = 5 ! OK, jvar appears in a locality spec66      kvar = 5 ! OK, kvar appears in a locality spec67 68!ERROR: Variable 'mvar' from an enclosing scope referenced in DO CONCURRENT with DEFAULT(NONE) must appear in a locality-spec69      mvar = 3.570    end do71  end associate72 73  select type ( a => p_or_c )74  type is ( point )75    do concurrent (i=1:5) local(a)76      ! C1130 This is OK because there's no DEFAULT(NONE) locality spec77      a%x = 3.578    end do79  end select80 81  select type ( a => p_or_c )82  type is ( point )83    do concurrent (i=1:5) default (none)84!ERROR: Variable 'a' from an enclosing scope referenced in DO CONCURRENT with DEFAULT(NONE) must appear in a locality-spec85      a%x = 3.586    end do87  end select88 89  select type ( a => p_or_c )90  type is ( point )91    do concurrent (i=1:5) default (none) local(a)92      ! C1130 This is OK because 'a' is in a locality-spec93      a%x = 3.594    end do95  end select96 97  x = 5.0  ! OK, we're not in a DO CONCURRENT98  99end subroutine s1100