+2005-10-12 Paul Thomas <pault@gcc.gnu.org>
+
+ PR fortran/18082
+ * decl.c (variable_decl): Make a new copy of the character
+ length for each variable, when the expression is not a
+ constant.
+
2005-10-12 Francois-Xavier Coudert <coudert@clipper.ens.fr>
* gfortran.h: Add bitmasks for different FPE traps. Add fpe
symbol table or the current interface. */
static match
-variable_decl (void)
+variable_decl (int elem)
{
char name[GFC_MAX_SYMBOL_LEN + 1];
gfc_expr *initializer, *char_len;
cl->length = char_len;
break;
+ /* Non-constant lengths need to be copied after the first
+ element. */
case MATCH_NO:
- cl = current_ts.cl;
+ if (elem > 1 && current_ts.cl->length
+ && current_ts.cl->length->expr_type != EXPR_CONSTANT)
+ {
+ cl = gfc_get_charlen ();
+ cl->next = gfc_current_ns->cl_list;
+ gfc_current_ns->cl_list = cl;
+ cl->length = gfc_copy_expr (current_ts.cl->length);
+ }
+ else
+ cl = current_ts.cl;
+
break;
case MATCH_ERROR:
{
gfc_symbol *sym;
match m;
+ int elem;
m = match_type_spec (¤t_ts, 0);
if (m != MATCH_YES)
if (m == MATCH_NO && current_ts.type == BT_CHARACTER && old_char_selector)
gfc_match_char (',');
- /* Give the types/attributes to symbols that follow. */
+ /* Give the types/attributes to symbols that follow. Give the element
+ a number so that repeat character length expressions can be copied. */
+ elem = 1;
for (;;)
{
- m = variable_decl ();
+ m = variable_decl (elem++);
if (m == MATCH_ERROR)
goto cleanup;
if (m == MATCH_NO)
2005-10-12 Paul Thomas <pault@gcc.gnu.org>
+ PR fortran/18082
+ gfortran.dg/automatic_char_len_1.f90: New test.
+
+2005-10-12 Paul Thomas <pault@gcc.gnu.org>
+
PR fortran/20847
gfortran.dg/save_common.f90: New test.