brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.9 KiB · 0fd2c42 Raw
187 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic2! Tests based on examples in C.10.63 4! C.10.6(10)5module m16  interface GOOD17    function F1A(X)8      real :: F1A, X9    end function10    function F1B(X)11      integer :: F1B, X12    end function13  end interface14end15 16! C.10.6(13)17module m218  interface GOOD219    function F2A(X)20      real :: F2A, X21    end function22    function F2B(X, Y)23      complex :: F2B24      real :: X, Y25    end function26  end interface27end28 29! C.10.6(15)30module m331  interface GOOD332    subroutine S3A(W, X, Y, Z)33      real :: W, Y34      integer :: X, Z35    end subroutine36    subroutine S3B(X, W, Z, Y)37      real :: W, Z38      integer :: X, Y39    end subroutine40  end interface41end42module m3b43  interface GOOD344    subroutine S3B(X, W, Z, Y)45      real :: W, Z46      integer :: X, Y47    end subroutine48    subroutine S3A(W, X, Y, Z)49      real :: W, Y50      integer :: X, Z51    end subroutine52  end interface53end54 55! C.10.6(17)56! BAD4(1.0,2,Y=3.0,Z=4) could apply to either procedure57module m458  !ERROR: Generic 'bad4' may not have specific procedures 's4a' and 's4b' as their interfaces are not distinguishable59  interface BAD460    subroutine S4A(W, X, Y, Z)61      real :: W, Y62      integer :: X, Z63    end subroutine64    subroutine S4B(X, W, Z, Y)65      real :: X, Y66      integer :: W, Z67    end subroutine68  end interface69end70module m4b71  !ERROR: Generic 'bad4' may not have specific procedures 's4b' and 's4a' as their interfaces are not distinguishable72  interface BAD473    subroutine S4B(X, W, Z, Y)74      real :: X, Y75      integer :: W, Z76    end subroutine77    subroutine S4A(W, X, Y, Z)78      real :: W, Y79      integer :: X, Z80    end subroutine81  end interface82end83 84! C.10.6(19)85module m586  interface GOOD587    subroutine S5A(X)88      real :: X89    end subroutine90    subroutine S5B(Y, X)91      real :: Y, X92    end subroutine93  end interface94end95 96module FRUITS97  type :: FRUIT98  end type99  type, extends(FRUIT) :: APPLE100  end type101  type, extends(FRUIT) :: PEAR102  end type103  type, extends(PEAR) :: BOSC104  end type105end106 107! C.10.6(21)108! type(PEAR) :: A_PEAR109! type(BOSC) :: A_BOSC110! BAD6(A_PEAR,A_BOSC)  ! could be s6a or s6b111module m6112  !ERROR: Generic 'bad6' may not have specific procedures 's6a' and 's6b' as their interfaces are not distinguishable113  interface BAD6114    subroutine S6A(X, Y)115      use FRUITS116      class(PEAR) :: X, Y117    end subroutine118    subroutine S6B(X, Y)119      use FRUITS120      class(FRUIT) :: X121      class(BOSC) :: Y122    end subroutine123  end interface124end125module m6b126  !ERROR: Generic 'bad6' may not have specific procedures 's6b' and 's6a' as their interfaces are not distinguishable127  interface BAD6128    subroutine S6B(X, Y)129      use FRUITS130      class(FRUIT) :: X131      class(BOSC) :: Y132    end subroutine133    subroutine S6A(X, Y)134      use FRUITS135      class(PEAR) :: X, Y136    end subroutine137  end interface138end139 140! C.10.6(22)141module m7142  interface GOOD7143    subroutine S7A(X, Y, Z)144      use FRUITS145      class(PEAR) :: X, Y, Z146    end subroutine147    subroutine S7B(X, Z, W)148      use FRUITS149      class(FRUIT) :: X150      class(BOSC) :: Z151      class(APPLE), optional :: W152    end subroutine153  end interface154end155module m7b156  interface GOOD7157    subroutine S7B(X, Z, W)158      use FRUITS159      class(FRUIT) :: X160      class(BOSC) :: Z161      class(APPLE), optional :: W162    end subroutine163    subroutine S7A(X, Y, Z)164      use FRUITS165      class(PEAR) :: X, Y, Z166    end subroutine167  end interface168end169 170! C.10.6(25)171! Invalid generic (according to the rules), despite the fact that it is unambiguous172module m8173  !PORTABILITY: Generic 'bad8' should not have specific procedures 's8a' and 's8b' as their interfaces are not distinguishable by the rules in the standard174  interface BAD8175    subroutine S8A(X, Y, Z)176      real, optional :: X177      integer :: Y178      real :: Z179    end subroutine180    subroutine S8B(X, Z, Y)181      integer, optional :: X182      integer :: Z183      real :: Y184    end subroutine185  end interface186end187