annotate gcc/testsuite/gfortran.dg/argument_checking_15.f90 @ 152:2b5abeee2509

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ! { dg-do compile }
kono
parents:
diff changeset
2 !
kono
parents:
diff changeset
3 ! PR fortran/32616
kono
parents:
diff changeset
4 !
kono
parents:
diff changeset
5 ! Check for to few elements of the actual argument
kono
parents:
diff changeset
6 ! and reject mismatching string lengths for assumed-shape dummies
kono
parents:
diff changeset
7 !
kono
parents:
diff changeset
8 implicit none
kono
parents:
diff changeset
9 external test
kono
parents:
diff changeset
10 integer :: i(10)
kono
parents:
diff changeset
11 integer :: j(2,2)
kono
parents:
diff changeset
12 character(len=4) :: str(2)
kono
parents:
diff changeset
13 character(len=4) :: str2(2,2)
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 call test()
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 call foo(i(8)) ! { dg-error "too few elements for dummy argument 'a' .3/4." }
kono
parents:
diff changeset
18 call foo(j(1,1))
kono
parents:
diff changeset
19 call foo(j(2,1)) ! { dg-error "too few elements for dummy argument 'a' .3/4." }
kono
parents:
diff changeset
20 call foo(j(1,2)) ! { dg-error "too few elements for dummy argument 'a' .2/4." }
kono
parents:
diff changeset
21
kono
parents:
diff changeset
22 str = 'FORT'
kono
parents:
diff changeset
23 str2 = 'fort'
kono
parents:
diff changeset
24 call bar(str(:)(1:2)) ! { dg-error "too few elements for dummy argument 'c' .4/6." }
kono
parents:
diff changeset
25 call bar(str(1:2)(1:1)) ! { dg-error "too few elements for dummy argument 'c' .2/6." }
kono
parents:
diff changeset
26 call bar(str(2)) ! { dg-error "too few elements for dummy argument 'c' .4/6." }
kono
parents:
diff changeset
27 call bar(str(1)(2:1)) ! OK
kono
parents:
diff changeset
28 call bar(str2(2,1)(4:1)) ! OK
kono
parents:
diff changeset
29 call bar(str2(1,2)(3:4)) ! OK
kono
parents:
diff changeset
30 call bar(str2(1,2)(4:4)) ! { dg-error "too few elements for dummy argument 'c' .5/6." }
kono
parents:
diff changeset
31 contains
kono
parents:
diff changeset
32 subroutine foo(a)
kono
parents:
diff changeset
33 integer :: a(4)
kono
parents:
diff changeset
34 end subroutine foo
kono
parents:
diff changeset
35 subroutine bar(c)
kono
parents:
diff changeset
36 character(len=2) :: c(3)
kono
parents:
diff changeset
37 ! print '(3a)', ':',c(1),':'
kono
parents:
diff changeset
38 ! print '(3a)', ':',c(2),':'
kono
parents:
diff changeset
39 ! print '(3a)', ':',c(3),':'
kono
parents:
diff changeset
40 end subroutine bar
kono
parents:
diff changeset
41 end
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 subroutine test()
kono
parents:
diff changeset
45 implicit none
kono
parents:
diff changeset
46 character(len=5), pointer :: c
kono
parents:
diff changeset
47 character(len=5) :: str(5)
kono
parents:
diff changeset
48 call foo(c) ! { dg-warning "Character length mismatch" }
kono
parents:
diff changeset
49 call bar(str) ! { dg-warning "Character length mismatch" }
kono
parents:
diff changeset
50 contains
kono
parents:
diff changeset
51 subroutine foo(a)
kono
parents:
diff changeset
52 character(len=3), pointer :: a
kono
parents:
diff changeset
53 end subroutine
kono
parents:
diff changeset
54 subroutine bar(a)
kono
parents:
diff changeset
55 character(len=3) :: a(:)
kono
parents:
diff changeset
56 end subroutine bar
kono
parents:
diff changeset
57 end subroutine test