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/defined_operators_1.f90 | |
download | cbb-gcc-4.6.4-upstream.tar.bz2 cbb-gcc-4.6.4-upstream.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/defined_operators_1.f90')
-rw-r--r-- | gcc/testsuite/gfortran.dg/defined_operators_1.f90 | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/gcc/testsuite/gfortran.dg/defined_operators_1.f90 b/gcc/testsuite/gfortran.dg/defined_operators_1.f90 new file mode 100644 index 000000000..c7868d14c --- /dev/null +++ b/gcc/testsuite/gfortran.dg/defined_operators_1.f90 @@ -0,0 +1,68 @@ +! { dg-do compile } +! { dg-options "-std=legacy" } +! Tests the fix for PR27122, in which the requirements of 12.3.2.1.1 +! for defined operators were not enforced. +! +! Based on PR test by Thomas Koenig <tkoenig@gcc.gnu.org> +! +module mymod + interface operator (.foo.) + module procedure foo_0 + module procedure foo_1 + module procedure foo_2 + module procedure foo_3 + module procedure foo_1_OK ! { dg-error "Ambiguous interfaces" } + module procedure foo_2_OK + function foo_chr (chr) ! { dg-error "cannot be assumed character length" } + character(*) :: foo_chr + character(*), intent(in) :: chr + end function foo_chr + end interface + + ! + ! PR fortran/33117 + ! PR fortran/46478 + ! Mixing FUNCTIONs and SUBROUTINEs in an INTERFACE hides the + ! errors that should be tested here. Hence split out subroutine + ! to test separately. + ! + interface operator (.bar.) + subroutine bad_foo (chr) ! { dg-error "must be a FUNCTION" } + character(*), intent(in) :: chr + end subroutine bad_foo + end interface + +contains + function foo_0 () ! { dg-error "must have at least one argument" } + integer :: foo_1 + foo_0 = 1 + end function foo_0 + function foo_1 (a) ! { dg-error "must be INTENT" } + integer :: foo_1 + integer :: a + foo_1 = 1 + end function foo_1 + function foo_1_OK (a) + integer :: foo_1_OK + integer, intent (in) :: a + foo_1_OK = 1 + end function foo_1_OK + function foo_2 (a, b) ! { dg-error "cannot be optional" } + integer :: foo_2 + integer, intent(in) :: a + integer, intent(in), optional :: b + foo_2 = 2 * a + b + end function foo_2 + function foo_2_OK (a, b) + real :: foo_2_OK + real, intent(in) :: a + real, intent(in) :: b + foo_2_OK = 2.0 * a + b + end function foo_2_OK + function foo_3 (a, b, c) ! { dg-error "must have, at most, two arguments" } + integer :: foo_3 + integer, intent(in) :: a, b, c + foo_3 = a + 3 * b - c + end function foo_3 +end module mymod +! { dg-final { cleanup-modules "mymod" } } |