URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gfortran.dg/] [impure_assignment_2.f90] - Rev 694
Compare with Previous | Blame | View Log
! { dg-do compile }! Tests the fix for PR20863 and PR20882, which were concerned with incorrect! application of constraints associated with "impure" variables in PURE! procedures.!! resolve.c (gfc_impure_variable) detects the following:! 12.6 Constraint: In a pure subprogram any variable which is in common or! accessed by host or use association, is a dummy argument to a pure function,! is a dummy argument with INTENT (IN) to a pure subroutine, or an object that! is storage associated with any such variable, shall not be used in the! following contexts: (clients of this function). */!! Contributed by Joost VandeVondele <jv244@cam.ac.uk>!MODULE pr20863TYPE node_typeTYPE(node_type), POINTER :: next=>null()END TYPECONTAINS! Original bug - pointer assignments to "impure" derived type with! pointer component.PURE FUNCTION give_next1(node)TYPE(node_type), POINTER :: nodeTYPE(node_type), POINTER :: give_nextgive_next => node%next ! { dg-error "Bad target" }node%next => give_next ! { dg-error "variable definition context" }END FUNCTION! Comment #2PURE integer FUNCTION give_next2(i)TYPE node_typesequenceTYPE(node_type), POINTER :: nextEND TYPETYPE(node_type), POINTER :: nodeTYPE(node_type), target :: tinteger, intent(in) :: inode%next = t ! This is OKgive_next2 = iEND FUNCTIONPURE FUNCTION give_next3(node)TYPE(node_type), intent(in) :: nodeTYPE(node_type) :: give_nextgive_next = node ! { dg-error "impure variable" }END FUNCTIONEND MODULE pr20863MODULE pr20882TYPE T1INTEGER :: IEND TYPE T1TYPE(T1), POINTER :: BCONTAINSPURE FUNCTION TST(A) RESULT(RES)TYPE(T1), INTENT(IN), TARGET :: ATYPE(T1), POINTER :: RESRES => A ! { dg-error "Bad target" }RES => B ! { dg-error "Bad target" }B => RES ! { dg-error "variable definition context" }END FUNCTIONPURE FUNCTION TST2(A) RESULT(RES)TYPE(T1), INTENT(IN), TARGET :: ATYPE(T1), POINTER :: RESallocate (RES)RES = AB = RES ! { dg-error "variable definition context" }RES = BEND FUNCTIONEND MODULE pr20882! { dg-final { cleanup-modules "pr20863 pr20882" } }
