73 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic2! Tests valid and invalid usage of forward references to procedures3! in specification expressions.4module m5 interface ifn26 module procedure if27 end interface8 interface ifn39 module procedure if310 end interface11 !ERROR: Automatic data object 'a' may not appear in a module12 real :: a(if1(1))13 !ERROR: Automatic data object 'b' may not appear in a module14 real :: b(ifn2(1))15 !ERROR: Automatic data object 'c' may not appear in COMMON block /blk/16 real :: c(if1(1))17 !ERROR: Automatic data object 'd' may not appear in COMMON block //18 real :: d(ifn2(1))19 common /blk/c20 common d21 contains22 subroutine t1(n)23 integer :: iarr(if1(n))24 end subroutine25 pure integer function if1(n)26 integer, intent(in) :: n27 if1 = n28 end function29 subroutine t2(n)30 integer :: iarr(ifn3(n)) ! should resolve to if331 end subroutine32 pure integer function if2(n)33 integer, intent(in) :: n34 if2 = n35 end function36 pure integer function if3(n)37 integer, intent(in) :: n38 if3 = n39 end function40end module41 42subroutine nester43 !ERROR: The internal function 'if1' may not be referenced in a specification expression44 real :: a(if1(1))45 contains46 subroutine t1(n)47 !ERROR: The internal function 'if2' may not be referenced in a specification expression48 integer :: iarr(if2(n))49 end subroutine50 pure integer function if1(n)51 integer, intent(in) :: n52 if1 = n53 end function54 pure integer function if2(n)55 integer, intent(in) :: n56 if2 = n57 end function58end subroutine59 60block data61 common /blk2/ n62 data n/100/63 !PORTABILITY: specification expression refers to local object 'n' (initialized and saved) [-Wsaved-local-in-spec-expr]64 !ERROR: Automatic data object 'a' may not appear in a BLOCK DATA subprogram65 real a(n)66end67 68program main69 common /blk2/ n70 !PORTABILITY: Automatic data object 'a' should not appear in the specification part of a main program [-Wautomatic-in-main-program]71 real a(n)72end73