[flang] Treat pre-processed input as fixed (#117563)
[llvm-project.git] / flang / test / Semantics / dim01.f90
blobaba9a15b95a41be3ddf3c6a0532742e162f14c03
1 ! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic
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 !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
22 f1 = norm2(a,dim=d)
23 end function
24 function f2(a,d)
25 real, intent(in) :: a(:)
26 integer, pointer, intent(in) :: d
27 !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
28 f2 = sum(a,dim=d)
29 end function
30 function f3(a,d)
31 real, intent(in) :: a(:)
32 integer, allocatable, intent(in) :: d
33 !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
34 f3 = sum(a,dim=d)
35 end function
36 function f10a(a)
37 real, intent(in) :: a(:,:)
38 real, allocatable :: f10a(:)
39 !ERROR: The value of DIM= (-1) may not be less than 1
40 f10a = sum(a,dim=-1)
41 end function
42 function f10b(a)
43 real, intent(in) :: a(:,:)
44 real, allocatable :: f10b(:)
45 !ERROR: The value of DIM= (3) may not be greater than 2
46 f10b = sum(a,dim=3)
47 end function
48 function f11(a,d)
49 real, intent(in) :: a(:,:)
50 integer, optional, intent(in) :: d
51 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
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
55 f11 = norm2(a,dim=d)
56 end function
57 function f12(a,d)
58 real, intent(in) :: a(:,:)
59 integer, pointer, intent(in) :: d
60 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
62 f12 = sum(a,dim=d)
63 end function
64 function f13(a,d)
65 real, intent(in) :: a(:,:)
66 integer, allocatable, intent(in) :: d
67 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
69 f13 = sum(a,dim=d)
70 end function
71 end module