aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/primary.c
diff options
context:
space:
mode:
authorPaul Thomas <pault@gcc.gnu.org>2007-09-05 13:34:25 +0000
committerPaul Thomas <pault@gcc.gnu.org>2007-09-05 13:34:25 +0000
commita99288e554007c0ac5ecfdc7733de19f1a1965dc (patch)
treecec6ce2218b24f0fa23d3e5fe993d76ef4a2d9e7 /gcc/fortran/primary.c
parent8e4bf5c78280d8a41ff53c09e73796fda078c278 (diff)
downloadgcc-a99288e554007c0ac5ecfdc7733de19f1a1965dc.zip
gcc-a99288e554007c0ac5ecfdc7733de19f1a1965dc.tar.gz
gcc-a99288e554007c0ac5ecfdc7733de19f1a1965dc.tar.bz2
re PR fortran/31564 (Error: Type/rank mismatch in argument)
2007-09-05 Paul Thomas <pault@gcc.gnu.org> PR fortran/31564 * primary.c (gfc_match_rvalue): Make expressions that refer to derived type parameters that have array references into variable expressions. Remove references to use association from the symbol. PR fortran/33241 * decl.c (add_init_expr_to_sym): Provide assumed character length parameters with the length of the initialization expression, if a constant, or that of the first element of an array. 2007-09-05 Paul Thomas <pault@gcc.gnu.org> PR fortran/31564 * gfortran.dg/derived_comp_array_ref_2.f90: New test. PR fortran/33241 * gfortran.dg/char_length_10.f90: New test. From-SVN: r128130
Diffstat (limited to 'gcc/fortran/primary.c')
-rw-r--r--gcc/fortran/primary.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c
index 2be27d7..f622996 100644
--- a/gcc/fortran/primary.c
+++ b/gcc/fortran/primary.c
@@ -2046,6 +2046,7 @@ gfc_match_rvalue (gfc_expr **result)
int i;
gfc_typespec *ts;
bool implicit_char;
+ gfc_ref *ref;
m = gfc_match_name (name);
if (m != MATCH_YES)
@@ -2143,6 +2144,34 @@ gfc_match_rvalue (gfc_expr **result)
e->symtree = symtree;
m = match_varspec (e, 0);
+
+ if (sym->ts.is_c_interop || sym->ts.is_iso_c)
+ break;
+
+ /* Variable array references to derived type parameters cause
+ all sorts of headaches in simplification. Make them variable
+ and scrub any module identity because they do not appear to
+ be referencable from the module. */
+ if (sym->value && sym->ts.type == BT_DERIVED && e->ref)
+ {
+ for (ref = e->ref; ref; ref = ref->next)
+ if (ref->type == REF_ARRAY)
+ break;
+
+ if (ref == NULL)
+ break;
+
+ ref = e->ref;
+ e->ref = NULL;
+ gfc_free_expr (e);
+ e = gfc_get_expr ();
+ e->expr_type = EXPR_VARIABLE;
+ e->symtree = symtree;
+ e->ref = ref;
+ sym->attr.use_assoc = 0;
+ sym->module = NULL;
+ }
+
break;
case FL_DERIVED: