Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/gfortran.dg/dependency_23.f90 @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 ! { dg-do run } | |
2 ! Test the fix for PR38863, in which an unnecessary temporary | |
3 ! generated results that are not consistent with other compilers. | |
4 ! | |
5 ! Contributed by Dick Hendrickson <dick.hendrickson@gmail.com> | |
6 ! | |
7 module rg0045_stuff | |
8 type unseq | |
9 integer :: i | |
10 logical :: l | |
11 end type unseq | |
12 interface assignment(=) | |
13 module procedure l_to_t, i_to_t | |
14 end interface | |
15 contains | |
16 elemental subroutine l_to_t (arg1, arg2) | |
17 type(unseq), intent(inout) :: arg1 | |
18 logical, intent(in) :: arg2 | |
19 arg1%l = arg2 | |
20 end subroutine l_to_t | |
21 elemental subroutine i_to_t (arg1, arg2) | |
22 type(unseq), intent(inout) :: arg1 | |
23 integer, intent(in) :: arg2 | |
24 arg1%i = arg2 | |
25 end subroutine i_to_t | |
26 subroutine rg0045(nf1, nf2, nf3) | |
27 type(unseq) :: tla2l(nf3, nf2) | |
28 type(unseq) :: tda2l(3,2) | |
29 logical :: lda(nf3,nf2) | |
30 tda2l%l = reshape ([.true.,.false.,.true.,.false.,.true.,.false.],[3,2]) | |
31 tda2l%i = reshape ([1, -1, 3, -1, 5, -1],[3,2]) | |
32 lda = tda2l%l | |
33 tla2l%l = lda | |
34 tla2l%i = reshape ([1, 2, 3, 4, 5, 6], [3,2]) | |
35 ! | |
36 ! The problem occurred here: gfortran was producing a temporary for these | |
37 ! assignments because the dependency checking was too restrictive. Since | |
38 ! a temporary was used, the integer component was reset in the first assignment | |
39 ! rather than being carried over. | |
40 ! | |
41 where(lda) | |
42 tla2l = tla2l(1:3, 1:2)%l | |
43 tla2l = tla2l(1:3, 1:2)%i | |
44 elsewhere | |
45 tla2l = -1 | |
46 endwhere | |
47 if (any (tla2l%i .ne. tda2l%i)) call abort | |
48 if (any (tla2l%l .neqv. tda2l%l)) call abort | |
49 end subroutine | |
50 end module rg0045_stuff | |
51 | |
52 use rg0045_stuff | |
53 call rg0045(1, 2, 3) | |
54 end |