brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.7 KiB · da1b80b Raw
193 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc12! Extended derived types3 4module m15  type :: t16    integer :: x7    !ERROR: Component 'x' is already declared in this derived type8    real :: x9  end type10end11 12module m213  type :: t114    integer :: i15  end type16  type, extends(t1) :: t217    !ERROR: Component 'i' is already declared in a parent of this derived type18    integer :: i19  end type20end21 22module m323  type :: t124  end type25  type, extends(t1) :: t226    integer :: i27    !ERROR: 't1' is a parent type of this type and so cannot be a component28    real :: t129  end type30  type :: t331  end type32  type, extends(t3) :: t433  end type34  type, extends(t4) :: t535    !ERROR: 't3' is a parent type of this type and so cannot be a component36    real :: t337  end type38end39 40module m441  type :: t142    integer :: t143  end type44  !ERROR: Type cannot be extended as it has a component named 't1'45  type, extends(t1) :: t246  end type47end48module m4a49  use m450  type, extends(t1) :: t3 ! ok, inaccessible component51  end type52end53 54module m555  type :: t156    integer :: t257  end type58  type, extends(t1) :: t259  end type60  !ERROR: Type cannot be extended as it has a component named 't2'61  type, extends(t2) :: t362  end type63end64 65module m666  ! t1 can be extended if it is known as anything but t367  type :: t168    integer :: t369  end type70  type, extends(t1) :: t271  end type72end73subroutine s674  use :: m6, only: t3 => t175  !ERROR: Type cannot be extended as it has a component named 't3'76  type, extends(t3) :: t477  end type78end79subroutine r680  use :: m6, only: t5 => t181  type, extends(t5) :: t682  end type83end84 85module m786  type, private :: t187    integer :: i188  end type89  type, extends(t1) :: t290    integer :: i291    integer, private :: i392  end type93  type :: t394    private95    integer :: i4 = 096    procedure(real), pointer, nopass :: pp1 => null()97  end type98  type, extends(t3) :: t499    private100    integer :: i5101    procedure(real), pointer, nopass :: pp2102  end type103end104subroutine s7105  use m7106  type(t2) :: x107  type(t4) :: y108  integer :: j109  j = x%i2110  !ERROR: PRIVATE name 'i3' is accessible only within module 'm7'111  j = x%i3112  !ERROR: PRIVATE name 't1' is accessible only within module 'm7'113  j = x%t1%i1114  !ok, parent component is not affected by PRIVATE in t4115  y%t3 = t3()116  !ERROR: PRIVATE name 'i4' is accessible only within module 'm7'117  y%i4 = 0118  !ERROR: PRIVATE name 'pp1' is accessible only within module 'm7'119  y%pp1 => null()120  !ERROR: PRIVATE name 'i5' is accessible only within module 'm7'121  y%i5 = 0122  !ERROR: PRIVATE name 'pp2' is accessible only within module 'm7'123  y%pp2 => null()124end125 126! 7.5.4.8(2)127module m8128  type  :: t129    integer :: i1130    integer, private :: i2131  end type132  type(t) :: y133  integer :: a(1)134contains135  subroutine s0136    type(t) :: x137    x = t(i1=2, i2=5)  !OK138  end139  subroutine s1140    a = [y%i2]  !OK141  end subroutine142end143subroutine s8144  use m8145  type(t) :: x146  !ERROR: PRIVATE name 'i2' is accessible only within module 'm8'147  x = t(2, 5)148  !ERROR: PRIVATE name 'i2' is accessible only within module 'm8'149  x = t(i1=2, i2=5)150  !ERROR: PRIVATE name 'i2' is accessible only within module 'm8'151  a = [y%i2]152end153 154! 7.5.4.8(2)155module m9156  interface157    module subroutine s()158    end subroutine159  end interface160  type  :: t161    integer :: i1162    integer, private :: i2163  end type164end165submodule(m9) sm8166contains167  module subroutine s168    type(t) :: x169    x = t(i1=2, i2=5)  !OK170  end171end172 173module m10174  type t175    integer n176   contains177    procedure :: f178    generic, private :: operator(+) => f179  end type180 contains181  type(t) function f(x,y)182    class(t), intent(in) :: x, y183    f = t(x%n + y%n)184  end function185end module186subroutine s10187  use m10188  type(t) x189  x = t(1)190  !ERROR: PRIVATE name 'operator(+)' is accessible only within module 'm10'191  x = x + x192end subroutine193