aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gfortran.dg/defined_operators_1.f90
diff options
context:
space:
mode:
authorBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
committerBen Cheng <bccheng@google.com>2014-03-25 22:37:19 -0700
commit1bc5aee63eb72b341f506ad058502cd0361f0d10 (patch)
treec607e8252f3405424ff15bc2d00aa38dadbb2518 /gcc-4.9/gcc/testsuite/gfortran.dg/defined_operators_1.f90
parent283a0bf58fcf333c58a2a92c3ebbc41fb9eb1fdb (diff)
downloadtoolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.gz
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.tar.bz2
toolchain_gcc-1bc5aee63eb72b341f506ad058502cd0361f0d10.zip
Initial checkin of GCC 4.9.0 from trunk (r208799).
Change-Id: I48a3c08bb98542aa215912a75f03c0890e497dba
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gfortran.dg/defined_operators_1.f90')
-rw-r--r--gcc-4.9/gcc/testsuite/gfortran.dg/defined_operators_1.f9067
1 files changed, 67 insertions, 0 deletions
diff --git a/gcc-4.9/gcc/testsuite/gfortran.dg/defined_operators_1.f90 b/gcc-4.9/gcc/testsuite/gfortran.dg/defined_operators_1.f90
new file mode 100644
index 000000000..9d9901853
--- /dev/null
+++ b/gcc-4.9/gcc/testsuite/gfortran.dg/defined_operators_1.f90
@@ -0,0 +1,67 @@
+! { 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