Bug 14081

Summary: Not Implemented: CHARACTER inside COMMON block
Product: gcc Reporter: Richard Biener <rguenth>
Component: fortranAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: enhancement CC: gcc-bugs
Priority: P2 Keywords: ice-on-valid-code, rejects-valid
Version: tree-ssa   
Target Milestone: tree-ssa   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2004-02-14 20:36:44

Description Richard Biener 2004-02-09 12:42:14 UTC
Trying to compile old fortran 77 code with gfortran the following code is not
recognized (which is a regression towards g77):

      PROGRAM test
      CHARACTER CHMODNAM*20
      COMMON /H2D_MODNAME/ CHMODNAM
      END

this is needed for g77 compatibility.
Comment 1 Andrew Pinski 2004-02-14 20:36:44 UTC
Confirmed.
Comment 2 GCC Commits 2004-04-04 23:27:59 UTC
Subject: Bug 14081

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	tree-ssa-20020619-branch
Changes by:	pbrook@gcc.gnu.org	2004-04-04 23:27:51

Modified files:
	gcc/fortran    : ChangeLog f95-lang.c gfortran.h trans-array.c 
	                 trans-common.c trans-const.c trans-const.h 
	                 trans-decl.c trans-expr.c trans-intrinsic.c 
	                 trans-io.c trans-stmt.c trans-types.c 
	                 trans-types.h trans.h 
	gcc/testsuite  : ChangeLog.tree-ssa 
Added files:
	gcc/testsuite/gfortran.fortran-torture/execute: strarray_1.f90 
	                                                strarray_2.f90 
	                                                strarray_3.f90 
	                                                strarray_4.f90 
	                                                strcommon_1.f90 

Log message:
	PR 13252
	PR 14081
	* f95-lang.c (gfc_init_builtin_functions): Add stack_alloc, stack_save
	and stack_restore.
	* gfortran.h (struct gfc_charlen): Add backend_decl.
	* trans-array.c (gfc_trans_allocate_temp_array,
	gfc_conv_temp_array_ref, gfc_conv_resolve_dependencies,
	(gfc_conv_loop_setup, gfc_array_allocate, gfc_conv_array_init_size):
	Remove old, broken string handling.
	(gfc_trans_auto_array_allocation, gfc_trans_g77_array,
	gfc_trans_dummy_array_bias, gfc_conv_expr_descriptor,
	gfc_trans_deferred_array): Handle character arrays.
	* trans-const.c (gfc_conv_const_charlen): New function.
	* trans-const.h (gfc_conv_const_charlen): Add prototype.
	* trans-decl.c (gfc_finish_var_decl): Don't mark automatic variables
	as static.
	(gfc_build_dummy_array_decl): Handle arrays with unknown element size.
	(gfc_create_string_length): New function.
	(gfc_get_symbol_decl): Create lengths for character variables.
	(gfc_get_fake_result_decl): Ditto.
	(gfc_build_function_decl): Only set length for assumed length
	character arguments.
	(gfc_trans_dummy_character): New function.
	(gfc_trans_auto_character_variable): Rewrite.
	(gfc_trans_deferred_vars): Handle more types of character variable.
	(gfc_create_module_variable): String lengths have moved.
	(gfc_generate_function_code): Initialize deferred var chain earlier.
	* trans-expr.c (gfc_conv_init_string_length): Rename ...
	(gfc_trans_init_string_length):  ... to this.
	(gfc_conv_component_ref, gfc_conv_variable, gfc_conv_concat_op,
	gfc_conv_function_call): Update to new format for character variables.
	(gfc_conv_string_length): Remove.
	(gfc_conv_string_parameter): Update assertion.
	* trans-intrinsic.c (gfc_conv_intrinsic_len): Use new location.
	* trans-io.c (set_string): Use new macro names.
	* trans-stmt.c (gfc_trans_label_assign. gfc_trans_goto): Ditto.
	* trans-types.c (gfc_get_character_type): Use existing length expr.
	(gfc_is_nodesc_array): Make public.
	(gfc_get_dtype_cst): Rename ...
	(gfc_get_dtype): ... to this.  Handle unknown size arrays.
	(gfc_get_nodesc_array_type): Use new name.
	(gfc_sym_type): New character variable code.
	(gfc_get_derived_type): Ditto.
	(gfc_get_function_type): Evaluate character variable lengths.
	* trans-types.h (gfc_strlen_kind): Define.
	(gfc_is_nodesc_array): Add prototype.
	* trans.h: Update prototypes.
	(struct lang_type): Update comments.
	(GFC_DECL_STRING_LEN): New name for GFC_DECL_STRING_LENGTH.
	(GFC_KNOWN_SIZE_STRING_TYPE): Remove.
	testsuite
	* gfortran.fortran-torture/execute/strarray_1.f90: New test.
	* gfortran.fortran-torture/execute/strarray_2.f90: New test.
	* gfortran.fortran-torture/execute/strarray_3.f90: New test.
	* gfortran.fortran-torture/execute/strarray_4.f90: New test.
	* gfortran.fortran-torture/execute/strcommon_1.f90: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.130&r2=1.1.2.131
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/f95-lang.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.18&r2=1.1.2.19
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/gfortran.h.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.11&r2=1.1.2.12
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-array.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.18&r2=1.1.2.19
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-common.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.4&r2=1.1.2.5
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-const.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.5&r2=1.1.2.6
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-const.h.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.3&r2=1.1.2.4
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-decl.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.34&r2=1.1.2.35
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-expr.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.20&r2=1.1.2.21
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-intrinsic.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.26&r2=1.1.2.27
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-io.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.8&r2=1.1.2.9
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-stmt.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.15&r2=1.1.2.16
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-types.c.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.13&r2=1.1.2.14
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans-types.h.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.2&r2=1.1.2.3
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/trans.h.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.14&r2=1.1.2.15
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.tree-ssa.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=1.1.2.213&r2=1.1.2.214
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.fortran-torture/execute/strarray_1.f90.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.fortran-torture/execute/strarray_2.f90.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.fortran-torture/execute/strarray_3.f90.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.fortran-torture/execute/strarray_4.f90.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=NONE&r2=1.1.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.fortran-torture/execute/strcommon_1.f90.diff?cvsroot=gcc&only_with_tag=tree-ssa-20020619-branch&r1=NONE&r2=1.1.2.1

Comment 3 Paul Brook 2004-04-04 23:29:28 UTC
Fixed.