From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/gfortran.dg/value_1.f90 | 84 +++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/value_1.f90 (limited to 'gcc/testsuite/gfortran.dg/value_1.f90') diff --git a/gcc/testsuite/gfortran.dg/value_1.f90 b/gcc/testsuite/gfortran.dg/value_1.f90 new file mode 100644 index 000000000..526a028ec --- /dev/null +++ b/gcc/testsuite/gfortran.dg/value_1.f90 @@ -0,0 +1,84 @@ +! { dg-do run } +! { dg-options "-std=f2003 -fall-intrinsics" } +! Tests the functionality of the patch for PR29642, which requested the +! implementation of the F2003 VALUE attribute for gfortran. +! +! Contributed by Paul Thomas +! +module global + type :: mytype + real(4) :: x + character(4) :: c + end type mytype +contains + subroutine typhoo (dt) + type(mytype), value :: dt + if (dtne (dt, mytype (42.0, "lmno"))) call abort () + dt = mytype (21.0, "wxyz") + if (dtne (dt, mytype (21.0, "wxyz"))) call abort () + end subroutine typhoo + + logical function dtne (a, b) + type(mytype) :: a, b + dtne = .FALSE. + if ((a%x /= b%x) .or. (a%c /= b%c)) dtne = .TRUE. + end function dtne +end module global + +program test_value + use global + integer(8) :: i = 42 + real(8) :: r = 42.0 + character(2) :: c = "ab" + complex(8) :: z = (-99.0, 199.0) + type(mytype) :: dt = mytype (42.0, "lmno") + + call foo (c) + if (c /= "ab") call abort () + + call bar (i) + if (i /= 42) call abort () + + call foobar (r) + if (r /= 42.0) call abort () + + call complex_foo (z) + if (z /= (-99.0, 199.0)) call abort () + + call typhoo (dt) + if (dtne (dt, mytype (42.0, "lmno"))) call abort () + + r = 20.0 + call foobar (r*2.0 + 2.0) + +contains + subroutine foo (c) + character(2), value :: c + if (c /= "ab") call abort () + c = "cd" + if (c /= "cd") call abort () + end subroutine foo + + subroutine bar (i) + integer(8), value :: i + if (i /= 42) call abort () + i = 99 + if (i /= 99) call abort () + end subroutine bar + + subroutine foobar (r) + real(8), value :: r + if (r /= 42.0) call abort () + r = 99.0 + if (r /= 99.0) call abort () + end subroutine foobar + + subroutine complex_foo (z) + COMPLEX(8), value :: z + if (z /= (-99.0, 199.0)) call abort () + z = (77.0, -42.0) + if (z /= (77.0, -42.0)) call abort () + end subroutine complex_foo + +end program test_value +! { dg-final { cleanup-modules "global" } } -- cgit v1.2.3