diff options
author | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
---|---|---|
committer | upstream source tree <ports@midipix.org> | 2015-03-15 20:14:05 -0400 |
commit | 554fd8c5195424bdbcabf5de30fdc183aba391bd (patch) | |
tree | 976dc5ab7fddf506dadce60ae936f43f58787092 /gcc/testsuite/gfortran.dg/typebound_proc_16.f03 | |
download | cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.bz2 cbb-gcc-4.6.4-554fd8c5195424bdbcabf5de30fdc183aba391bd.tar.xz |
obtained gcc-4.6.4.tar.bz2 from upstream website;upstream
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.
Diffstat (limited to 'gcc/testsuite/gfortran.dg/typebound_proc_16.f03')
-rw-r--r-- | gcc/testsuite/gfortran.dg/typebound_proc_16.f03 | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/typebound_proc_16.f03 b/gcc/testsuite/gfortran.dg/typebound_proc_16.f03 new file mode 100644 index 000000000..828f51022 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/typebound_proc_16.f03 @@ -0,0 +1,58 @@ +! { dg-do compile } +! +! PR 44549: [OOP][F2008] Type-bound procedure: bogus error from list after PROCEDURE +! +! Contributed by Dominique d'Humieres <dominiq@lps.ens.fr> + +MODULE rational_numbers + IMPLICIT NONE + PRIVATE + TYPE,PUBLIC :: rational + PRIVATE + INTEGER n,d + + CONTAINS + ! ordinary type-bound procedure + PROCEDURE :: real => rat_to_real + ! specific type-bound procedures for generic support + PROCEDURE,PRIVATE :: rat_asgn_i, rat_plus_rat, rat_plus_i + PROCEDURE,PRIVATE,PASS(b) :: i_plus_rat + ! generic type-bound procedures + GENERIC :: ASSIGNMENT(=) => rat_asgn_i + GENERIC :: OPERATOR(+) => rat_plus_rat, rat_plus_i, i_plus_rat + END TYPE + CONTAINS + ELEMENTAL REAL FUNCTION rat_to_real(this) RESULT(r) + CLASS(rational),INTENT(IN) :: this + r = REAL(this%n)/this%d + END FUNCTION + + ELEMENTAL SUBROUTINE rat_asgn_i(a,b) + CLASS(rational),INTENT(OUT) :: a + INTEGER,INTENT(IN) :: b + a%n = b + a%d = 1 + END SUBROUTINE + + ELEMENTAL TYPE(rational) FUNCTION rat_plus_i(a,b) RESULT(r) + CLASS(rational),INTENT(IN) :: a + INTEGER,INTENT(IN) :: b + r%n = a%n + b*a%d + r%d = a%d + END FUNCTION + + ELEMENTAL TYPE(rational) FUNCTION i_plus_rat(a,b) RESULT(r) + INTEGER,INTENT(IN) :: a + CLASS(rational),INTENT(IN) :: b + r%n = b%n + a*b%d + r%d = b%d + END FUNCTION + + ELEMENTAL TYPE(rational) FUNCTION rat_plus_rat(a,b) RESULT(r) + CLASS(rational),INTENT(IN) :: a,b + r%n = a%n*b%d + b%n*a%d + r%d = a%d*b%d + END FUNCTION +END + +! { dg-final { cleanup-modules "rational_numbers" } } |