1! { dg-do compile }
2! { dg-options "-g -fdec-structure" }
3!
4! Test a regression where typespecs of unions containing character buffers of
5! different lengths where copied, resulting in a bad gimple tree state.
6!
7
8subroutine sub2 (otherbuf)
9  integer, parameter :: L_bbuf = 65536
10  integer, parameter :: L_bbuf2 = 24
11
12  structure /buffer2/
13    union
14     map
15      character(L_bbuf2)  sbuf
16     end map
17    end union
18  end structure
19  structure /buffer/
20    union
21     map
22      character(L_bbuf)  sbuf
23     end map
24    end union
25  end structure
26
27  record /buffer/ buf1
28  record /buffer2/ buf2
29  common /c/ buf1, buf2
30
31  record /buffer2/ otherbuf
32end subroutine
33
34subroutine sub()
35  integer, parameter :: L_bbuf = 65536
36  integer, parameter :: L_bbuf2 = 24
37
38  structure /buffer2/
39    union
40     map
41      character(L_bbuf2)  sbuf
42     end map
43    end union
44  end structure
45  structure /buffer/
46    union
47     map
48      character(L_bbuf)  sbuf
49     end map
50    end union
51  end structure
52
53  record /buffer/ buf1
54  record /buffer2/ buf2
55  common /c/ buf1, buf2
56
57  call sub2 (buf1) ! { dg-warning "Type mismatch" }
58  return
59end subroutine
60
61call sub()
62
63end
64