From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/gfortran.dg/ichar_1.f90 | 71 +++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/ichar_1.f90 (limited to 'gcc/testsuite/gfortran.dg/ichar_1.f90') diff --git a/gcc/testsuite/gfortran.dg/ichar_1.f90 b/gcc/testsuite/gfortran.dg/ichar_1.f90 new file mode 100644 index 000000000..362cd2f45 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/ichar_1.f90 @@ -0,0 +1,71 @@ +! { dg-do compile } +! { dg-options "-std=legacy" } +! +! 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 length +subroutine test (c) + character(len=*) :: c + integer i + i = ichar(c) + i = ichar(c(2:)) + i = ichar(c(:1)) +end subroutine + +program 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 -- cgit v1.2.3