OSDN Git Service

2010-04-24 Kai Tietz <kai.tietz@onevision.com>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gfortran.dg / transfer_array_intrinsic_3.f90
1 ! { dg-do run }\r
2 ! Tests fix for PR31193, in which the character length for MOLD in\r
3 ! case 1 below was not being translated correctly for character\r
4 ! constants and an ICE ensued.  The further cases are either checks\r
5 ! or new bugs that were found in the course of development cases 3 & 5.\r
6 !\r
7 ! Contributed by Brooks Moses <brooks@gcc.gnu.org>\r
8 !\r
9 function NumOccurances (string, chr, isel) result(n)\r
10   character(*),intent(in) :: string\r
11   character(1),intent(in) :: chr\r
12   integer :: isel\r
13 !\r
14 ! return number of occurances of character in given string\r
15 !\r
16     select case (isel)\r
17       case (1)\r
18       n=count(transfer(string, char(1), len(string))==chr)\r
19       case (2)\r
20       n=count(transfer(string, chr, len(string))==chr)\r
21       case (3)\r
22       n=count(transfer(string, "a", len(string))==chr)\r
23       case (4)\r
24       n=count(transfer(string, (/"a","b"/), len(string))==chr)\r
25       case (5)\r
26       n=count(transfer(string, string(1:1), len(string))==chr)\r
27     end select\r
28   return\r
29 end\r
30 \r
31   if (NumOccurances("abacadae", "a", 1) .ne. 4) call abort ()\r
32   if (NumOccurances("abacadae", "a", 2) .ne. 4) call abort ()\r
33   if (NumOccurances("abacadae", "a", 3) .ne. 4) call abort ()\r
34   if (NumOccurances("abacadae", "a", 4) .ne. 4) call abort ()\r
35   if (NumOccurances("abacadae", "a", 5) .ne. 4) call abort ()\r
36 end\r