c: Fix up pointer types to may_alias structures [PR114493]
[official-gcc.git] / gcc / testsuite / gfortran.dg / array_temporaries_4.f90
blobd022ce8855739ff7ade8702985be59859262646b
1 ! { dg-do compile }
2 ! { dg-options "-Warray-temporaries" }
3 ! Tests the fix for PR80164, in which the compiler segfaulted on this
4 ! when using -Warray-temporaries
6 !******************************************************************************
7 module global
8 type :: a
9 integer :: b
10 character(8):: c
11 end type a
12 interface assignment(=)
13 module procedure a_to_a, c_to_a, a_to_c
14 end interface
15 interface operator(.ne.)
16 module procedure a_ne_a
17 end interface
19 type(a) :: x(4), y(4)
20 logical :: l1(4), t = .true., f= .false.
21 contains
22 !******************************************************************************
23 elemental subroutine a_to_a (m, n)
24 type(a), intent(in) :: n
25 type(a), intent(out) :: m
26 m%b = len ( trim(n%c))
27 m%c = n%c
28 end subroutine a_to_a
29 elemental subroutine c_to_a (m, n)
30 character(8), intent(in) :: n
31 type(a), intent(out) :: m
32 m%b = m%b + 1
33 m%c = n
34 end subroutine c_to_a
35 elemental subroutine a_to_c (m, n)
36 type(a), intent(in) :: n
37 character(8), intent(out) :: m
38 m = n%c
39 end subroutine a_to_c
40 !******************************************************************************
41 elemental logical function a_ne_a (m, n)
42 type(a), intent(in) :: n
43 type(a), intent(in) :: m
44 a_ne_a = (m%b .ne. n%b) .or. (m%c .ne. n%c)
45 end function a_ne_a
46 !******************************************************************************
47 elemental function foo (m)
48 type(a) :: foo
49 type(a), intent(in) :: m
50 foo%b = 0
51 foo%c = m%c
52 end function foo
53 end module global
54 !******************************************************************************
55 program test
56 use global
57 x = (/a (0, "one"),a (0, "two"),a (0, "three"),a (0, "four")/) ! { dg-warning "Creating array temporary" }
58 y = x
59 end program test