Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Semantics / dim01.f90
blob48c0291b58f9e1cc49580beae3a0bc96feb95833
1 ! RUN: %python %S/test_errors.py %s %flang_fc1
2 ! Test warnings and errors about DIM= arguments to transformational intrinsics
4 module m
5 contains
6 function f0a(a)
7 real, intent(in) :: a(:)
8 !ERROR: The value of DIM= (-1) may not be less than 1
9 f0a = sum(a,dim=-1)
10 end function
11 function f0b(a)
12 real, intent(in) :: a(:)
13 !ERROR: The value of DIM= (2) may not be greater than 1
14 f0b = sum(a,dim=2)
15 end function
16 function f1(a,d)
17 real, intent(in) :: a(:)
18 integer, optional, intent(in) :: d
19 !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
20 f1 = sum(a,dim=d)
21 end function
22 function f2(a,d)
23 real, intent(in) :: a(:)
24 integer, pointer, intent(in) :: d
25 !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
26 f2 = sum(a,dim=d)
27 end function
28 function f3(a,d)
29 real, intent(in) :: a(:)
30 integer, allocatable, intent(in) :: d
31 !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
32 f3 = sum(a,dim=d)
33 end function
34 function f10a(a)
35 real, intent(in) :: a(:,:)
36 real, allocatable :: f10a(:)
37 !ERROR: The value of DIM= (-1) may not be less than 1
38 f10a = sum(a,dim=-1)
39 end function
40 function f10b(a)
41 real, intent(in) :: a(:,:)
42 real, allocatable :: f10b(:)
43 !ERROR: The value of DIM= (3) may not be greater than 2
44 f10b = sum(a,dim=3)
45 end function
46 function f11(a,d)
47 real, intent(in) :: a(:,:)
48 integer, optional, intent(in) :: d
49 real, allocatable :: f11(:)
50 !WARNING: The actual argument for DIM= is optional, pointer, or allocatable, and may not be absent during execution; parenthesize to silence this warning
51 f11 = sum(a,dim=d)
52 end function
53 function f12(a,d)
54 real, intent(in) :: a(:,:)
55 integer, pointer, intent(in) :: d
56 real, allocatable :: f12(:)
57 !WARNING: The actual argument for DIM= is optional, pointer, or allocatable, and may not be absent during execution; parenthesize to silence this warning
58 f12 = sum(a,dim=d)
59 end function
60 function f13(a,d)
61 real, intent(in) :: a(:,:)
62 integer, allocatable, intent(in) :: d
63 real, allocatable :: f13(:)
64 !WARNING: The actual argument for DIM= is optional, pointer, or allocatable, and may not be absent during execution; parenthesize to silence this warning
65 f13 = sum(a,dim=d)
66 end function
67 end module