brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · 16f5618 Raw
78 lines · plain
1! RUN: %python %S/test_errors.py %s %flang_fc1 -pedantic2module m3  use iso_c_binding4  type haslen(L)5    integer, len :: L6  end type7  integer, target :: targ8 contains9  subroutine subr10  end11  subroutine test(assumedType, poly, nclen, n)12    type(*), target :: assumedType13    class(*), target ::  poly14    type(c_ptr) cp15    type(c_funptr) cfp16    real notATarget17    !PORTABILITY: Procedure pointer 'pptr' should not have an ELEMENTAL intrinsic as its interface [-Wportability]18    procedure(sin), pointer :: pptr19    real, target :: arr(3)20    type(hasLen(1)), target :: clen21    type(hasLen(*)), target :: nclen22    integer, intent(in) :: n23    character(2), target :: ch24    character(1,4), target :: unicode25    real :: arr1(purefun1(c_loc(targ))) ! ok26    real :: arr2(purefun2(c_funloc(subr))) ! ok27    character(:), allocatable, target :: deferred28    character(n), pointer :: p2ch29    !ERROR: C_LOC() argument must be a data pointer or target30    cp = c_loc(notATarget)31    !ERROR: C_LOC() argument must be a data pointer or target32    cp = c_loc(pptr)33    !ERROR: C_LOC() argument must be contiguous34    cp = c_loc(arr(1:3:2))35    !ERROR: C_LOC() argument may not be a zero-sized array36    cp = c_loc(arr(3:1))37    !ERROR: C_LOC() argument must have an intrinsic type, assumed type, or non-polymorphic derived type with no non-constant length parameter38    cp = c_loc(poly)39    cp = c_loc(clen) ! ok40    !ERROR: C_LOC() argument must have an intrinsic type, assumed type, or non-polymorphic derived type with no non-constant length parameter41    cp = c_loc(nclen)42    !ERROR: C_LOC() argument may not be zero-length character43    cp = c_loc(ch(2:1))44    !WARNING: C_LOC() argument has non-interoperable character length [-Wcharacter-interoperability]45    cp = c_loc(ch)46    !WARNING: C_LOC() argument has non-interoperable intrinsic type or kind [-Winteroperability]47    cp = c_loc(unicode)48    cp = c_loc(ch(1:1)) ! ok49    cp = c_loc(deferred) ! ok50    cp = c_loc(p2ch) ! ok51    !ERROR: PRIVATE name '__address' is accessible only within module '__fortran_builtins'52    cp = c_ptr(0)53    !ERROR: PRIVATE name '__address' is accessible only within module '__fortran_builtins'54    cfp = c_funptr(0)55    !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types TYPE(c_ptr) and TYPE(c_funptr)56    cp = cfp57    !ERROR: No intrinsic or user-defined ASSIGNMENT(=) matches operand types TYPE(c_funptr) and TYPE(c_ptr)58    cfp = cp59  end60  pure integer function purefun1(p)61    type(c_ptr), intent(in) :: p62    purefun1 = 163  end64  pure integer function purefun2(p)65    type(c_funptr), intent(in) :: p66    purefun2 = 167  end68end module69 70module m271  use iso_c_binding72  ! In this context (structure constructor from intrinsic module being used directly73  ! in another module), emit only a warning, since this module might have originally74  ! been a module file that was converted back into Fortran.75  !WARNING: PRIVATE name '__address' is accessible only within module '__fortran_builtins'76  type(c_ptr) :: p = c_ptr(0)77end78