Bug 29431 - Not Implemented: complex character array constructors
Summary: Not Implemented: complex character array constructors
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2006-10-11 15:55 UTC by Paul Thomas
Modified: 2006-11-12 07:43 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.2.0 4.1.2
Last reconfirmed: 2006-10-30 21:50:34


Attachments
This fixes the immediate problem of the lack of a character length. (499 bytes, patch)
2006-10-13 09:20 UTC, Paul Thomas
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Thomas 2006-10-11 15:55:50 UTC
In fixing PR29373, I separated off the part to do with the function declaration from that triggered by the constructor.

! { dg-do compile }
! Tests patch for PR29373, in which the implicit character
! statement messes up the function declaration because the
! requisite functions in decl.c were told nothing about
! implicit types.
!
! Contributed by Tobias Schlueter  <tobi@gcc.gnu.org>
!
  implicit character*32 (a-z)
  CHARACTER(len=255), DIMENSION(1,2)  :: a

! Reporters original, which triggers another error:
! gfc_todo: Not Implemented: complex character array
! constructors. 

  a = reshape((/ to_string(1.0) /), (/ 1, 2 /)) ! uncommented

  a = to_string(1.0)
  print *, a
  CONTAINS
    FUNCTION to_string(x)
      character*32 to_string ! moved from function declaration.
      REAL, INTENT(in) :: x
      WRITE(to_string, FMT="(F6.3)") x
    END FUNCTION
END PROGRAM

does this

[prt@localhost pr29373]# /svn-4.2/bin/gfortran  pr29373a.f90
pr29373a.f90: In function ‘MAIN__’:
pr29373a.f90:24: fatal error: gfc_todo: Not Implemented: complex character array constructors
compilation terminated.

Paul
Comment 1 Paul Thomas 2006-10-13 09:20:03 UTC
Created attachment 12422 [details]
This fixes the immediate problem of the lack of a character length.

I find that, except for constant constructors, the need for padding is not detected at all.  Thus the case above segfaults with this patch, unless supplied with enough elements.

Paul
Comment 2 patchapp@dberlin.org 2006-11-09 00:20:42 UTC
Subject: Bug number PR29431

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/2006-11/msg00532.html
Comment 3 Paul Thomas 2006-11-09 22:49:25 UTC
Subject: Bug 29431

Author: pault
Date: Thu Nov  9 22:49:12 2006
New Revision: 118631

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118631
Log:
2006-11-09 Paul Thomas <pault@gcc.gnu.org>

	PR fortran/29431
	* trans-array.c    (get_array_ctor_strlen): If we fall through to
	default, use a constant character length if it is available.

2006-11-09 Paul Thomas <pault@gcc.gnu.org>

	PR fortran/29431
	* gfortran.dg/array_constructor_13.f90: New test.

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

Comment 4 Paul Thomas 2006-11-12 07:40:48 UTC
Subject: Bug 29431

Author: pault
Date: Sun Nov 12 07:40:26 2006
New Revision: 118719

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118719
Log:
2006-11-12 Paul Thomas <pault@gcc.gnu.org>

	PR fortran/29699
	* trans-array.c (structure_alloc_comps): Detect pointers to
	arrays and use indirect reference to declaration.
	* resolve.c (resolve_fl_variable): Tidy up condition.
	(resolve_symbol): The same and only add initialization code if
	the symbol is referenced.
	* trans-decl.c (gfc_trans_deferred_vars): Call gfc_trans_
	deferred_array before gfc_trans_auto_array_allocation.

	PR fortran/21730
	* symbol.c (check_done): Remove.
	(gfc_add_attribute): Remove reference to check_done and remove
	the argument attr_intent.
	(gfc_add_allocatable, gfc_add_dimension, gfc_add_external,
	gfc_add_intrinsic, gfc_add_optional, gfc_add_pointer,
	gfc_add_cray_pointer, gfc_add_cray_pointee, gfc_add_result,
	gfc_add_target, gfc_add_in_common, gfc_add_elemental,
	gfc_add_pure, gfc_add_recursive, gfc_add_procedure,
	gfc_add_type): Remove references to check_done.
	* decl.c (attr_decl1): Eliminate third argument in call to
	gfc_add_attribute.
	* gfortran.h : Change prototype for gfc_add_attribute.

	PR fortran/29431
	* trans-array.c    (get_array_ctor_strlen): If we fall through to
	default, use a constant character length if it is available.

	PR fortran/29758
	* check.c (gfc_check_reshape): Check that there are enough
	elements in the source array as to be able to fill an array
	defined by shape, when pad is absent.

	PR fortran/29315
	* trans-expr.c (is_aliased_array): Treat correctly the case where the
	component is itself and array or array reference.


2006-11-12 Paul Thomas <pault@gcc.gnu.org>

	PR fortran/29699
	* gfortran.dg/alloc_comp_auto_array_1.f90: New test.

	PR fortran/21730
	* gfortran.dg/change_symbol_attributes_1.f90: New test.

	PR fortran/29431
	* gfortran.dg/array_constructor_13.f90: New test.

	PR fortran/29758
	* gfortran.dg/reshape_source_size_1.f90: New test.

	PR fortran/29315
	* gfortran.dg/aliasing_dummy_4.f90: New test.

Added:
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/aliasing_dummy_4.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/alloc_comp_auto_array_1.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/array_constructor_13.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/change_symbol_attributes_1.f90
    branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/reshape_source_size_1.f90
Modified:
    branches/gcc-4_2-branch/gcc/fortran/ChangeLog
    branches/gcc-4_2-branch/gcc/fortran/check.c
    branches/gcc-4_2-branch/gcc/fortran/decl.c
    branches/gcc-4_2-branch/gcc/fortran/gfortran.h
    branches/gcc-4_2-branch/gcc/fortran/resolve.c
    branches/gcc-4_2-branch/gcc/fortran/symbol.c
    branches/gcc-4_2-branch/gcc/fortran/trans-array.c
    branches/gcc-4_2-branch/gcc/fortran/trans-decl.c
    branches/gcc-4_2-branch/gcc/fortran/trans-expr.c
    branches/gcc-4_2-branch/gcc/testsuite/ChangeLog

Comment 5 Paul Thomas 2006-11-12 07:43:09 UTC
Fixed on trunk and 4.2. 4.1 will follow next weekend.

Paul