summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/dec_union_11.f90
blob: 41e23b267efe57fc6790f3f848cf2dd52ee4a5b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
! { dg-do compile }
! { dg-options "-g -fdec-structure -std=legacy" }
!
! Test a regression where typespecs of unions containing character buffers of
! different lengths where copied, resulting in a bad gimple tree state.
!

subroutine sub2 (otherbuf)
  integer, parameter :: L_bbuf = 65536
  integer, parameter :: L_bbuf2 = 24

  structure /buffer2/
    union
     map
      character(L_bbuf2)  sbuf
     end map
    end union
  end structure
  structure /buffer/
    union
     map
      character(L_bbuf)  sbuf
     end map
    end union
  end structure

  record /buffer/ buf1
  record /buffer2/ buf2
  common /c/ buf1, buf2

  record /buffer2/ otherbuf
end subroutine

subroutine sub()
  integer, parameter :: L_bbuf = 65536
  integer, parameter :: L_bbuf2 = 24

  structure /buffer2/
    union
     map
      character(L_bbuf2)  sbuf
     end map
    end union
  end structure
  structure /buffer/
    union
     map
      character(L_bbuf)  sbuf
     end map
    end union
  end structure

  record /buffer/ buf1
  record /buffer2/ buf2
  common /c/ buf1, buf2

  call sub2 (buf1) ! { dg-warning "Type mismatch" }
  return
end subroutine

call sub()

end