PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gfortran.dg / typebound_override_1.f90
blob7eb685615f46ba631b7d2820541383422e29446d
1 ! { dg-do compile }
3 ! PR 49638: [OOP] length parameter is ignored when overriding type bound character functions with constant length.
5 ! Original test case contributed by Hans-Werner Boschmann <boschmann@tp1.physik.uni-siegen.de>
7 module m
9 implicit none
11 type :: t1
12 contains
13 procedure, nopass :: a => a1
14 procedure, nopass :: b => b1
15 procedure, nopass :: c => c1
16 procedure, nopass :: d => d1
17 procedure, nopass :: e => e1
18 end type
20 type, extends(t1) :: t2
21 contains
22 procedure, nopass :: a => a2 ! { dg-error "Character length mismatch in function result" }
23 procedure, nopass :: b => b2 ! { dg-error "Rank mismatch in function result" }
24 procedure, nopass :: c => c2 ! FIXME: dg-warning "Possible character length mismatch"
25 procedure, nopass :: d => d2 ! valid, check for commutativity (+,*)
26 procedure, nopass :: e => e2 ! { dg-error "Character length mismatch in function result" }
27 end type
29 contains
31 function a1 ()
32 character(len=6) :: a1
33 end function
35 function a2 ()
36 character(len=7) :: a2
37 end function
39 function b1 ()
40 integer :: b1
41 end function
43 function b2 ()
44 integer, dimension(2) :: b2
45 end function
47 function c1 (x)
48 integer, intent(in) :: x
49 character(2*x) :: c1
50 end function
52 function c2 (x)
53 integer, intent(in) :: x
54 character(3*x) :: c2
55 end function
57 function d1 (y)
58 integer, intent(in) :: y
59 character(2*y+1) :: d1
60 end function
62 function d2 (y)
63 integer, intent(in) :: y
64 character(1+y*2) :: d2
65 end function
67 function e1 (z)
68 integer, intent(in) :: z
69 character(3) :: e1
70 end function
72 function e2 (z)
73 integer, intent(in) :: z
74 character(z) :: e2
75 end function
77 end module m
82 module w1
84 implicit none
86 integer :: n = 1
88 type :: tt1
89 contains
90 procedure, nopass :: aa => aa1
91 end type
93 contains
95 function aa1 (m)
96 integer, intent(in) :: m
97 character(n+m) :: aa1
98 end function
100 end module w1
103 module w2
105 use w1, only : tt1
107 implicit none
109 integer :: n = 2
111 type, extends(tt1) :: tt2
112 contains
113 procedure, nopass :: aa => aa2 ! FIXME: dg-warning "Possible character length mismatch"
114 end type
116 contains
118 function aa2 (m)
119 integer, intent(in) :: m
120 character(n+m) :: aa2
121 end function
123 end module w2