101 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic2! C15773program main4 type t1(k,l)5 integer, kind :: k = kind(1)6 integer, len :: l = 6667 integer(k) n8 end type t19 interface10 pure integer function ifunc()11 end function12 end interface13 !PORTABILITY: Automatic data object 'x1' should not appear in the specification part of a main program [-Wautomatic-in-main-program]14 type(t1(k=4,l=ifunc())) x115 !PORTABILITY: Statement function 'sf1' should not contain an array constructor [-Wstatement-function-extensions]16 sf1(n) = sum([(j,j=1,n)])17 type(t1) sf218 !PORTABILITY: Statement function 'sf2' should not contain a structure constructor [-Wstatement-function-extensions]19 sf2(n) = t1(n)20 !PORTABILITY: Statement function 'sf3' should not contain a type parameter inquiry [-Wstatement-function-extensions]21 sf3(n) = x1%l22 !ERROR: Recursive call to statement function 'sf4' is not allowed23 sf4(n) = sf4(n)24 !ERROR: Statement function 'sf5' may not reference another statement function 'sf6' that is defined later25 sf5(n) = sf6(n)26 real sf727 !ERROR: Statement function 'sf6' may not reference another statement function 'sf7' that is defined later28 sf6(n) = sf7(n)29 !PORTABILITY: Statement function 'sf7' should not reference function 'explicit' that requires an explicit interface [-Wstatement-function-extensions]30 sf7(n) = explicit(n)31 real :: a(3) = [1., 2., 3.]32 !PORTABILITY: Statement function 'sf8' should not pass an array argument that is not a whole array [-Wstatement-function-extensions]33 sf8(n) = sum(a(1:2))34 sf8a(n) = sum(a) ! ok35 integer :: sf936 !ERROR: Defining expression of statement function 'sf9' cannot be converted to its result type INTEGER(4)37 sf9(n) = "bad"38 !ERROR: Statement function 'sf10' may not reference another statement function 'sf11' that is defined later39 sf10(n) = sf11(n)40 sf11(n) = sf10(n) ! mutual recursion, caused crash41 integer(1) iarg142 !PORTABILITY: nonstandard usage: based POINTER43 pointer(iarg1p, iarg1)44 sf13(iarg1) = iarg145 ! executable part46 print *, sf13(iarg1) ! ok47 sf14 = 1.48 contains49 real function explicit(x,y)50 integer, intent(in) :: x51 integer, intent(in), optional :: y52 explicit = x53 end function54 pure function arr()55 real :: arr(2)56 arr = [1., 2.]57 end function58 subroutine foo59 !PORTABILITY: An implicitly typed statement function should not appear when the same symbol is available in its host scope [-Wstatement-function-extensions]60 sf14(x) = 2.*x61 end subroutine62end63 64subroutine s065 allocatable :: sf66 !ERROR: 'sf' is not a callable procedure67 sf(x) = 1.68end69 70subroutine s171 asynchronous :: sf72 !ERROR: An entity may not have the ASYNCHRONOUS attribute unless it is a variable73 sf(x) = 1.74end75 76subroutine s277 pointer :: sf78 !ERROR: A statement function must not have the POINTER attribute79 sf(x) = 1.80end81 82subroutine s383 save :: sf84 !ERROR: The entity 'sf' with an explicit SAVE attribute must be a variable, procedure pointer, or COMMON block85 sf(x) = 1.86end87 88subroutine s489 volatile :: sf90 !ERROR: VOLATILE attribute may apply only to a variable91 sf(x) = 1.92end93 94subroutine s595 !ERROR: Invalid specification expression: reference to impure function 'k'96 real x(k())97 !WARNING: Name 'k' from host scope should have a type declaration before its local statement function definition [-Wstatement-function-extensions]98 !ERROR: 'k' is already declared in this scoping unit99 k() = 0.0100end101