* cfgloopmanip.c (duplicate_loop_to_header_edge): Cleanup profile
[official-gcc.git] / gcc / testsuite / gfortran.dg / proc_ptr_comp_33.f90
blob55a768017fa84d2f098d9ae483bf7ce3fb3d5a46
1 ! { dg-do compile }
3 ! PR 48095: [OOP] Invalid assignment to procedure pointer component not rejected
5 ! Original test case by Arjen Markus <arjen.markus895@gmail.com>
6 ! Modified by Janus Weil <janus@gcc.gnu.org>
8 module m
10 implicit none
12 type :: rectangle
13 real :: width, height
14 procedure(get_area_ai), pointer :: get_area => get_my_area ! { dg-error "Type mismatch in argument" }
15 end type rectangle
17 abstract interface
18 real function get_area_ai( this )
19 import :: rectangle
20 class(rectangle), intent(in) :: this
21 end function get_area_ai
22 end interface
24 contains
26 real function get_my_area( this )
27 type(rectangle), intent(in) :: this
28 get_my_area = 3.0 * this%width * this%height
29 end function get_my_area
31 end
33 !-------------------------------------------------------------------------------
35 program p
37 implicit none
39 type :: rectangle
40 real :: width, height
41 procedure(get_area_ai), pointer :: get_area
42 end type rectangle
44 abstract interface
45 real function get_area_ai (this)
46 import :: rectangle
47 class(rectangle), intent(in) :: this
48 end function get_area_ai
49 end interface
51 type(rectangle) :: rect
53 rect = rectangle (1.0, 2.0, get1)
54 rect = rectangle (3.0, 4.0, get2) ! { dg-error "Type mismatch in argument" }
56 contains
58 real function get1 (this)
59 class(rectangle), intent(in) :: this
60 get1 = 1.0 * this%width * this%height
61 end function get1
63 real function get2 (this)
64 type(rectangle), intent(in) :: this
65 get2 = 2.0 * this%width * this%height
66 end function get2
68 end