aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/expr.c
diff options
context:
space:
mode:
authorDaniel Franke <franke.daniel@gmail.com>2007-12-18 18:39:56 -0500
committerDaniel Franke <dfranke@gcc.gnu.org>2007-12-18 18:39:56 -0500
commit106dbde4b6239ffcffe1c480780921b0387e858a (patch)
tree4a0f5a35f0cffb8801a01fd7818abf666ed82794 /gcc/fortran/expr.c
parent520f6c8df8c48a5fd3c15e80e4853d638d28a715 (diff)
downloadgcc-106dbde4b6239ffcffe1c480780921b0387e858a.zip
gcc-106dbde4b6239ffcffe1c480780921b0387e858a.tar.gz
gcc-106dbde4b6239ffcffe1c480780921b0387e858a.tar.bz2
re PR fortran/34495 (accepts invalid initialization expressions withTRANSFER)
gcc/fortran: 2007-12-19 Daniel Franke <franke.daniel@gmail.com> PR fortran/34495 * expr.c (check_init_expr): Check whether variables with flavor FL_PARAMETER do have a value assigned. Added error messages where appropriate. * simplify.c (gfc_simplify_transfer): Added check if the MOLD argument is a constant if working with initialization expressions. gcc/testsuite: 2007-12-19 Daniel Franke <franke.daniel@gmail.com> PR fortran/34495 * gfortran.dg/transfer_simplify_2.f90: Fixed invalid initialization expressions. * gfortran.dg/transfer_simplify_7.f90: New test. From-SVN: r131047
Diffstat (limited to 'gcc/fortran/expr.c')
-rw-r--r--gcc/fortran/expr.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 92ad77e..4e77605 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -2202,7 +2202,18 @@ check_init_expr (gfc_expr *e)
if (e->symtree->n.sym->attr.flavor == FL_PARAMETER)
{
- t = simplify_parameter_variable (e, 0);
+ /* A PARAMETER shall not be used to define itself, i.e.
+ REAL, PARAMETER :: x = transfer(0, x)
+ is invalid. */
+ if (!e->symtree->n.sym->value)
+ {
+ gfc_error("PARAMETER '%s' is used at %L before its definition "
+ "is complete", e->symtree->n.sym->name, &e->where);
+ t = FAILURE;
+ }
+ else
+ t = simplify_parameter_variable (e, 0);
+
break;
}
@@ -2233,6 +2244,12 @@ check_init_expr (gfc_expr *e)
e->symtree->n.sym->name, &e->where);
break;
+ case AS_EXPLICIT:
+ gfc_error ("Array '%s' at %L is a variable, which does "
+ "not reduce to a constant expression",
+ e->symtree->n.sym->name, &e->where);
+ break;
+
default:
gcc_unreachable();
}