summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gfortran.dg/elemental_result_2.f90
blob: 490c2ef68de0ef6159eee6531b3d54f456c5192d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
! { dg-do compile }
!
! Test part of the fix for PR99124 which adds errors for class results
! That violate F2018, C15100.
!
! Contributed by Gerhard Steinmetz  <gscfq@t-online.de>
!
module m
   type t
      integer :: i
   contains
      procedure :: f
      generic :: operator(+) => f
   end type
contains
   elemental function f(a, b) &
   result(c)                     ! { dg-error "shall not have an ALLOCATABLE or POINTER attribute" }
      class(t), intent(in) :: a, b
      class(t), allocatable :: c
      c = t(a%i + b%i)
   end
   elemental function g(a, b) &
   result(c)                     ! { dg-error "shall not have an ALLOCATABLE or POINTER attribute" }
      class(t), intent(in) :: a, b
      class(t), pointer :: c
      c => null ()
   end
   elemental function h(a, b) &  ! { dg-error "must have a scalar result" }
   result(c)                     ! { dg-error "must be dummy, allocatable or pointer" }
      class(t), intent(in) :: a, b
      class(t) :: c(2)
   end
end