⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ichar_1.f90

📁 linux下编程用 编译软件
💻 F90
字号:
! { dg-do compile }! PR20879! Check that we reject expressions longer than one character for the! ICHAR and IACHAR intrinsics.! Assumed length variables are special because the frontend doesn't have! an expression for their lengthsubroutine test (c)  character(len=*) :: c  integer i  i = ichar(c)  i = ichar(c(2:))  i = ichar(c(:1))end subroutineprogram ichar_1   type derivedtype      character(len=4) :: addr   end type derivedtype   type derivedtype1      character(len=1) :: addr   end type derivedtype1   integer i   integer, parameter :: j = 2   character(len=8) :: c = 'abcd'   character(len=1) :: g1(2)   character(len=1) :: g2(2,2)   character*1, parameter :: s1 = 'e'   character*2, parameter :: s2 = 'ef'   type(derivedtype) :: dt   type(derivedtype1) :: dt1   if (ichar(c(3:3)) /= 97) call abort   if (ichar(c(:1)) /= 97) call abort   if (ichar(c(j:j)) /= 98) call abort   if (ichar(s1) /= 101) call abort   if (ichar('f') /= 102) call abort   g1(1) = 'a'   if (ichar(g1(1)) /= 97) call abort   if (ichar(g1(1)(:)) /= 97) call abort   g2(1,1) = 'a'   if (ichar(g2(1,1)) /= 97) call abort   i = ichar(c)      ! { dg-error "must be of length one" "" }   i = ichar(c(:))   ! { dg-error "must be of length one" "" }   i = ichar(s2)     ! { dg-error "must be of length one" "" }   i = ichar(c(1:2)) ! { dg-error "must be of length one" "" }   i = ichar(c(1:))  ! { dg-error "must be of length one" "" }   i = ichar('abc')  ! { dg-error "must be of length one" "" }   ! ichar and iachar use the same checking routines. DO a couple of tests to   ! make sure it's not totally broken.   if (ichar(c(3:3)) /= 97) call abort   i = ichar(c)      ! { dg-error "must be of length one" "" }      i = ichar(dt%addr(1:1))   i = ichar(dt%addr) ! { dg-error "must be of length one" "" }   i = ichar(dt%addr(1:2)) ! { dg-error "must be of length one" "" }   i = ichar(dt%addr(1:)) ! { dg-error "must be of length one" "" }      i = ichar(dt1%addr(1:1))   i = ichar(dt1%addr)   call test(g1(1))end program ichar_1

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -