public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Patch, fortran] PR32875 - Not Implemented: complex character array  constructor
@ 2007-08-17  6:01 Paul Thomas
  2007-08-17 20:12 ` Jerry DeLisle
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Thomas @ 2007-08-17  6:01 UTC (permalink / raw)
  To: Fortran List, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 756 bytes --]

:ADDPATCH fortran:

This patch is self-explanatory and acts as a backstop in translating 
character array constructors.  Notice that the length, in this case, 
should, strictly speaking be one.  However, the precise value of the 
character length of a zero length array seems to be an academic nicety 
to me.  Note also that LEN (this constructor) gives the right value 
because it is simplified correctly.

Regtests amd64/Cygwin_NT - OK for trunk?

Paul

2007-08-17  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/32875
    * trans-array.c    (get_array_ctor_strlen): Set the character
    length of a zero length array to zero.

2007-08-17  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/32875
    * gfortran.dg/array_constructor_18.f90: New test.



[-- Attachment #2: pr32875.diff --]
[-- Type: text/x-patch, Size: 1385 bytes --]

Index: gcc/fortran/trans-array.c
===================================================================
*** gcc/fortran/trans-array.c	(revision 127505)
--- gcc/fortran/trans-array.c	(working copy)
*************** get_array_ctor_strlen (stmtblock_t *bloc
*** 1421,1426 ****
--- 1421,1433 ----
    bool is_const;
    
    is_const = TRUE;
+ 
+   if (c == NULL)
+     {
+       *len = build_int_cstu (gfc_charlen_type_node, 0);
+       return is_const;
+     }
+ 
    for (; c; c = c->next)
      {
        switch (c->expr->expr_type)
Index: gcc/testsuite/gfortran.dg/array_constructor_18.f90
===================================================================
*** gcc/testsuite/gfortran.dg/array_constructor_18.f90	(revision 0)
--- gcc/testsuite/gfortran.dg/array_constructor_18.f90	(revision 0)
***************
*** 0 ****
--- 1,19 ----
+ ! { dg-do compile }
+ ! Tests the fix for PR32875, in which the character length for the
+ ! array constructor would get lost in simplification and would lead
+ ! the error 'Not Implemented: complex character array constructor'.
+ !
+ ! Contributed by Joost VandeVondele <jv244@cam.ac.uk>
+ !
+   call foo ((/(S1(i),i=1,3,-1)/))
+ CONTAINS
+   FUNCTION S1(i)
+     CHARACTER(LEN=1) :: S1
+     INTEGER :: I
+     S1="123456789"(i:i)
+   END FUNCTION S1
+   subroutine foo (chr)
+     character(1) :: chr(:)
+     print *, chr
+   end subroutine
+ END

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, fortran] PR32875 - Not Implemented: complex character  array constructor
  2007-08-17  6:01 [Patch, fortran] PR32875 - Not Implemented: complex character array constructor Paul Thomas
@ 2007-08-17 20:12 ` Jerry DeLisle
  2007-08-18 11:21   ` Paul Thomas
  0 siblings, 1 reply; 3+ messages in thread
From: Jerry DeLisle @ 2007-08-17 20:12 UTC (permalink / raw)
  To: Paul Thomas; +Cc: Fortran List, gcc-patches

Paul Thomas wrote:
> :ADDPATCH fortran:
> 
> This patch is self-explanatory and acts as a backstop in translating 
> character array constructors.  Notice that the length, in this case, 
> should, strictly speaking be one.  However, the precise value of the 
> character length of a zero length array seems to be an academic nicety 
> to me.  Note also that LEN (this constructor) gives the right value 
> because it is simplified correctly.
> 
> Regtests amd64/Cygwin_NT - OK for trunk?
> 
> Paul
> 
Looks OK Paul,

Jerry

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch, fortran] PR32875 - Not Implemented: complex character   array constructor
  2007-08-17 20:12 ` Jerry DeLisle
@ 2007-08-18 11:21   ` Paul Thomas
  0 siblings, 0 replies; 3+ messages in thread
From: Paul Thomas @ 2007-08-18 11:21 UTC (permalink / raw)
  To: Jerry DeLisle; +Cc: Fortran List, gcc-patches

Jerry,
>>
> Looks OK Paul,
>
This and PR32881 have been committed - thanks

Paul

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-08-18 11:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-17  6:01 [Patch, fortran] PR32875 - Not Implemented: complex character array constructor Paul Thomas
2007-08-17 20:12 ` Jerry DeLisle
2007-08-18 11:21   ` Paul Thomas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).