Bug 32875 - Not Implemented: complex character array constructor
Not Implemented: complex character array constructor
Status: RESOLVED FIXED
Product: gcc
Classification: Unclassified
Component: fortran
4.3.0
: P3 normal
: 4.3.0
Assigned To: Paul Thomas
: rejects-valid
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2007-07-24 08:56 UTC by Joost VandeVondele
Modified: 2007-08-18 10:41 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.3.0
Last reconfirmed: 2007-08-14 16:36:40


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joost VandeVondele 2007-07-24 08:56:26 UTC
write(6,*) (/(S1(i),i=1,3,-1)/)
CONTAINS
FUNCTION S1(i)
 CHARACTER(LEN=1) :: S1
 INTEGER :: I
 S1="123456789"(i:i)
END FUNCTION S1
END
Comment 1 Tobias Burnus 2007-07-24 10:09:58 UTC
Error message:

fatal error: gfc_todo: Not Implemented: complex character array constructors
compilation terminated.
Comment 2 Francois-Xavier Coudert 2007-08-14 09:04:21 UTC
  write(6,*) (/(s1(),i=1,3,-1)/)
  !write(6,*) shape((/(s1(),i=1,3,-1)/))
contains
  function s1()
    character(len=1) :: s1
    s1=" "
  end function s1
end

Further reduced: no need for the substring in s1. You can also get an ICE by replacing the first WRITE statement with one using SHAPE.
Comment 3 Paul Thomas 2007-08-14 16:36:40 UTC
This fixes it but there are one or two regressions that I need to investigate.

Paul

Index: gcc/fortran/trans-array.c
===================================================================
*** gcc/fortran/trans-array.c   (revision 127396)
--- 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)
Comment 4 patchapp@dberlin.org 2007-08-17 15:10:26 UTC
Subject: Bug number PR32875

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-08/msg01077.html
Comment 5 Paul Thomas 2007-08-18 08:34:54 UTC
Subject: Bug 32875

Author: pault
Date: Sat Aug 18 08:34:42 2007
New Revision: 127608

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127608
Log:
2007-08-18  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-18  Paul Thomas  <pault@gcc.gnu.org>

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


Added:
    trunk/gcc/testsuite/gfortran.dg/array_constructor_18.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-array.c
    trunk/gcc/testsuite/ChangeLog

Comment 6 Paul Thomas 2007-08-18 10:40:36 UTC
Fixed on trunk

Paul
Comment 7 Paul Thomas 2007-08-18 10:41:43 UTC
It helps to mark it as fixed....