File: argument_checking_2.f90

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (31 lines) | stat: -rw-r--r-- 1,353 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
! { dg-do compile }
! { dg-options "-std=f95" }
!
! PR fortran/30940
program main
  implicit none
  character(len=10) :: digit_string = '123456789', str
  character :: digit_arr(10)
  call copy(digit_string, digit_arr)  ! { dg-error "Scalar CHARACTER actual argument with array dummy argument 'in'" }
  call copy(digit_arr,str)            ! { dg-error "Scalar CHARACTER actual argument with array dummy argument 'out'" }
  if(str /= '123456789') STOP 1
  digit_string = 'qwertasdf'
  call copy2(digit_string, digit_arr) ! { dg-error "Scalar CHARACTER actual argument with array dummy argument 'in'" }
  call copy2(digit_arr,str) ! { dg-error "Scalar CHARACTER actual argument with array dummy argument 'out'" }
  if(str /= 'qwertasdf') STOP 2
  digit_string = '1qayxsw23e'
  call copy('1qayxsw23e', digit_arr) ! { dg-error "Scalar CHARACTER actual argument with array dummy argument 'in'" }
  call copy(digit_arr,str) ! { dg-error "Scalar CHARACTER actual argument with array dummy argument 'out'" }
  if(str /= '1qayxsw23e') STOP 3
contains
  subroutine copy(in, out)
    character, dimension(*)  :: in
    character, dimension(10) :: out
    out = in(:10)
  end subroutine copy
  subroutine copy2(in, out)
    character, dimension(2,*)  :: in
    character, dimension(2,5) :: out
    out(1:2,1:5) = in(1:2,1:5)
  end subroutine copy2
end program main