summaryrefslogtreecommitdiff
path: root/gcc/fortran/decl.c
diff options
context:
space:
mode:
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>2005-10-12 20:29:21 +0000
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>2005-10-12 20:29:21 +0000
commit3923b69f425942813467f05a97628cce628cb260 (patch)
tree162f353f0d18f7abe39f8eb26326940ad6f0a652 /gcc/fortran/decl.c
parent8c84a5de8ea015ec2e463b480ec81f03671b1e43 (diff)
downloadgcc-3923b69f425942813467f05a97628cce628cb260.tar.gz
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 Paul Thomas <pault@gcc.gnu.org> PR fortran/18082 gfortran.dg/automatic_char_len_1.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105329 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fortran/decl.c')
-rw-r--r--gcc/fortran/decl.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 8c4ce585e43..20d1f8a2d20 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -900,7 +900,7 @@ gfc_match_null (gfc_expr ** result)
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;
@@ -944,8 +944,20 @@ variable_decl (void)
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:
@@ -1944,6 +1956,7 @@ gfc_match_data_decl (void)
{
gfc_symbol *sym;
match m;
+ int elem;
m = match_type_spec (&current_ts, 0);
if (m != MATCH_YES)
@@ -1995,10 +2008,12 @@ ok:
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)