diff options
author | Paul Thomas <pault@gcc.gnu.org> | 2007-07-24 19:15:27 +0000 |
---|---|---|
committer | Paul Thomas <pault@gcc.gnu.org> | 2007-07-24 19:15:27 +0000 |
commit | 08113c7398f734fdabf27af9d143af83ebde3767 (patch) | |
tree | 32b8097802564b8678cba249265de7ae9a445e64 /gcc/fortran/symbol.c | |
parent | b21a6ea1002424fcb2b3d5d5661526ce7abbb358 (diff) | |
download | gcc-08113c7398f734fdabf27af9d143af83ebde3767.zip gcc-08113c7398f734fdabf27af9d143af83ebde3767.tar.gz gcc-08113c7398f734fdabf27af9d143af83ebde3767.tar.bz2 |
re PR fortran/31205 (aliased operator assignment produces wrong result)
2007-07-24 Paul Thomas <pault@gcc.gnu.org>
PR fortran/31205
PR fortran/32842
* trans-expr.c (gfc_conv_function_call): Remove the default
initialization of intent(out) derived types.
* symbol.c (gfc_lval_expr_from_sym): New function.
* matchexp.c (gfc_get_parentheses): Return argument, if it is
character and posseses a ref.
* gfortran.h : Add prototype for gfc_lval_expr_from_sym.
* resolve.c (has_default_initializer): Move higher up in file.
(resolve_code): On detecting an interface assignment, check
if the rhs and the lhs are the same symbol. If this is so,
enclose the rhs in parenetheses to generate a temporary and
prevent any possible aliasing.
(apply_default_init): Remove code making the lval and call
gfc_lval_expr_from_sym instead.
(resolve_operator): Give a parentheses expression a type-
spec if it has no type.
* trans-decl.c (gfc_trans_deferred_vars): Apply the a default
initializer, if any, to an intent(out) derived type, using
gfc_lval_expr_from_sym and gfc_trans_assignment. Check if
the dummy is present.
2007-07-24 Paul Thomas <pault@gcc.gnu.org>
PR fortran/31205
* gfortran.dg/alloc_comp_basics_1.f90 : Restore number of
"deallocates" to 24, since patch has code rid of much spurious
code.
* gfortran.dg/interface_assignment_1.f90 : New test.
PR fortran/32842
* gfortran.dg/interface_assignment_2.f90 : New test.
From-SVN: r126885
Diffstat (limited to 'gcc/fortran/symbol.c')
-rw-r--r-- | gcc/fortran/symbol.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index 32fe1f1..af42e9b 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -1959,6 +1959,35 @@ done: } +/*******A helper function for creating new expressions*************/ + + +gfc_expr * +gfc_lval_expr_from_sym (gfc_symbol *sym) +{ + gfc_expr *lval; + lval = gfc_get_expr (); + lval->expr_type = EXPR_VARIABLE; + lval->where = sym->declared_at; + lval->ts = sym->ts; + lval->symtree = gfc_find_symtree (sym->ns->sym_root, sym->name); + + /* It will always be a full array. */ + lval->rank = sym->as ? sym->as->rank : 0; + if (lval->rank) + { + lval->ref = gfc_get_ref (); + lval->ref->type = REF_ARRAY; + lval->ref->u.ar.type = AR_FULL; + lval->ref->u.ar.dimen = lval->rank; + lval->ref->u.ar.where = sym->declared_at; + lval->ref->u.ar.as = sym->as; + } + + return lval; +} + + /************** Symbol table management subroutines ****************/ /* Basic details: Fortran 95 requires a potentially unlimited number |