mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-16 05:01:56 +00:00
f6ded53fb0
Calls to C_F_POINTER() without the optional SHAPE= third argument were failing to be recognized as proper calls to the intrinsic, but the failure was not generating any error message. This led to a crash in lowering, which rightfully expects a typed expression to be associated with the call. So (1) catch silent failures to convert CALL statements as internal errors, as is done for expressions and assignment statements; and (2) clean up C_F_POINTER intrinsic handling to cope with only two arguments and to emit an error for a FPTR= argument with no type. Differential Revision: https://reviews.llvm.org/D119847
35 lines
1.5 KiB
Fortran
35 lines
1.5 KiB
Fortran
! RUN: %python %S/test_errors.py %s %flang_fc1
|
|
! Enforce 18.2.3.3
|
|
|
|
program test
|
|
use iso_c_binding, only: c_ptr, c_f_pointer
|
|
type(c_ptr) :: scalarC, arrayC(1)
|
|
type :: with_pointer
|
|
integer, pointer :: p
|
|
end type
|
|
type(with_pointer) :: coindexed[*]
|
|
integer, pointer :: scalarIntF, arrayIntF(:)
|
|
character(len=:), pointer :: charDeferredF
|
|
integer :: j
|
|
call c_f_pointer(scalarC, scalarIntF) ! ok
|
|
call c_f_pointer(scalarC, arrayIntF, [1_8]) ! ok
|
|
call c_f_pointer(shape=[1_8], cptr=scalarC, fptr=arrayIntF) ! ok
|
|
call c_f_pointer(scalarC, shape=[1_8], fptr=arrayIntF) ! ok
|
|
!ERROR: A positional actual argument may not appear after any keyword arguments
|
|
call c_f_pointer(scalarC, fptr=arrayIntF, [1_8])
|
|
!ERROR: CPTR= argument to C_F_POINTER() must be a C_PTR
|
|
call c_f_pointer(j, scalarIntF)
|
|
!ERROR: CPTR= argument to C_F_POINTER() must be scalar
|
|
call c_f_pointer(arrayC, scalarIntF)
|
|
!ERROR: SHAPE= argument to C_F_POINTER() must appear when FPTR= is an array
|
|
call c_f_pointer(scalarC, arrayIntF)
|
|
!ERROR: SHAPE= argument to C_F_POINTER() may not appear when FPTR= is scalar
|
|
call c_f_pointer(scalarC, scalarIntF, [1_8])
|
|
!ERROR: FPTR= argument to C_F_POINTER() may not have a deferred type parameter
|
|
call c_f_pointer(scalarC, charDeferredF)
|
|
!ERROR: FPTR= argument to C_F_POINTER() may not be a coindexed object
|
|
call c_f_pointer(scalarC, coindexed[0]%p)
|
|
!ERROR: FPTR= argument to C_F_POINTER() must have a type
|
|
call c_f_pointer(scalarC, null())
|
|
end program
|