From 1283ab121d8d5ef620e27fcdf4349321dbb0352f Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Tue, 25 Dec 2007 13:05:23 +0100 Subject: re PR fortran/34514 (Accepts invalid: Dimensions specified for N after initialisation) 2007-12-25 Tobias Burnus PR fortran/34514 * decl.c (attr_decl1): Reject specifying the DIMENSION for already initialized variable. (do_parm): Reject PARAMETER for already initialized variable. 2007-12-25 Tobias Burnus PR fortran/34514 * gfortran.dg/initialization_17.f90: New. From-SVN: r131169 --- gcc/fortran/decl.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'gcc/fortran/decl.c') diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 072477e..dd8eb35 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -5151,6 +5151,14 @@ attr_decl1 (void) goto cleanup; } + if (current_attr.dimension && sym->value) + { + gfc_error ("Dimensions specified for %s at %L after its " + "initialisation", sym->name, &var_locus); + m = MATCH_ERROR; + goto cleanup; + } + if ((current_attr.allocatable || current_attr.pointer) && (m == MATCH_YES) && (as->type != AS_DEFERRED)) { @@ -5753,6 +5761,13 @@ do_parm (void) goto cleanup; } + if (sym->value) + { + gfc_error ("Initializing already initialized variable at %C"); + m = MATCH_ERROR; + goto cleanup; + } + if (sym->ts.type == BT_CHARACTER && sym->ts.cl != NULL && sym->ts.cl->length != NULL -- cgit v1.1