72 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic2! Test warnings and errors about DIM= arguments to transformational intrinsics3 4module m5 contains6 function f0a(a)7 real, intent(in) :: a(:)8 !ERROR: The value of DIM= (-1) may not be less than 19 f0a = sum(a,dim=-1)10 end function11 function f0b(a)12 real, intent(in) :: a(:)13 !ERROR: The value of DIM= (2) may not be greater than 114 f0b = sum(a,dim=2)15 end function16 function f1(a,d)17 real, intent(in) :: a(:)18 integer, optional, intent(in) :: d19 !PORTABILITY: The actual argument for DIM= is optional, pointer, or allocatable, and it is assumed to be present and equal to 1 at execution time [-Woptional-must-be-present]20 f1 = sum(a,dim=d)21 !PORTABILITY: The actual argument for DIM= is optional, pointer, or allocatable, and it is assumed to be present and equal to 1 at execution time [-Woptional-must-be-present]22 f1 = norm2(a,dim=d)23 end function24 function f2(a,d)25 real, intent(in) :: a(:)26 integer, pointer, intent(in) :: d27 !PORTABILITY: The actual argument for DIM= is optional, pointer, or allocatable, and it is assumed to be present and equal to 1 at execution time [-Woptional-must-be-present]28 f2 = sum(a,dim=d)29 end function30 function f3(a,d)31 real, intent(in) :: a(:)32 integer, allocatable, intent(in) :: d33 !PORTABILITY: The actual argument for DIM= is optional, pointer, or allocatable, and it is assumed to be present and equal to 1 at execution time [-Woptional-must-be-present]34 f3 = sum(a,dim=d)35 end function36 function f10a(a)37 real, intent(in) :: a(:,:)38 real, allocatable :: f10a(:)39 !ERROR: The value of DIM= (-1) may not be less than 140 f10a = sum(a,dim=-1)41 end function42 function f10b(a)43 real, intent(in) :: a(:,:)44 real, allocatable :: f10b(:)45 !ERROR: The value of DIM= (3) may not be greater than 246 f10b = sum(a,dim=3)47 end function48 function f11(a,d)49 real, intent(in) :: a(:,:)50 integer, optional, intent(in) :: d51 real, allocatable :: f11(:)52 !WARNING: The actual argument for DIM= is optional, pointer, or allocatable, and may not be absent during execution; parenthesize to silence this warning [-Woptional-must-be-present]53 f11 = sum(a,dim=d)54 !WARNING: The actual argument for DIM= is optional, pointer, or allocatable, and may not be absent during execution; parenthesize to silence this warning [-Woptional-must-be-present]55 f11 = norm2(a,dim=d)56 end function57 function f12(a,d)58 real, intent(in) :: a(:,:)59 integer, pointer, intent(in) :: d60 real, allocatable :: f12(:)61 !WARNING: The actual argument for DIM= is optional, pointer, or allocatable, and may not be absent during execution; parenthesize to silence this warning [-Woptional-must-be-present]62 f12 = sum(a,dim=d)63 end function64 function f13(a,d)65 real, intent(in) :: a(:,:)66 integer, allocatable, intent(in) :: d67 real, allocatable :: f13(:)68 !WARNING: The actual argument for DIM= is optional, pointer, or allocatable, and may not be absent during execution; parenthesize to silence this warning [-Woptional-must-be-present]69 f13 = sum(a,dim=d)70 end function71end module72