This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[fortran, ptach] initialization expressions, update
- From: Daniel Franke <franke dot daniel at gmail dot com>
- To: fortran at gcc dot gnu dot org
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 22 Jul 2007 23:45:05 +0200
- Subject: [fortran, ptach] initialization expressions, update
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:from:to:subject:date:user-agent:cc:mime-version:message-id:content-type; b=TmeF1bjNhuIReyLOr7VoIqkaboMjnMGrwPEKdXjsIxuVhO0244Ob3K6bpDSTNpL3gJOWU5YlPaUNPnZaqi5ApTbeo4iZmvDYAElpr2mQbNLI4YKtJxGSiF2/MyYdONSaJ2iVq/4iWXsBtQ19a9B18NYc5k6dtYvRnP4RXjs19hY=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:from:to:subject:date:user-agent:cc:mime-version:message-id:content-type; b=sIHKkaG9HAUk2imnaetC15mE5XYaSLrNpBDJZYmHSnA+XHqJ4H+dhj/XdTGEHAwOE6XW1JswMzNFQJWcKXV0JbVnksB1yyUs9vTVBXom7/CwRFC6kfDh05D4L0fifi2JST1jUbgtFQFabMvM+wa2uGlsvSVKupzbib0L3XaE9AM=
The original testcase of PR31639 still results in an ICE if -std=gnu but is
handled correctly if -std=f95 or -std=f2003. This update changes the related
gfc_notify_std() to gfc_error().
Further, as F2003 allows more transformational intrinsics in initialization
expressions than F95, we ICE on those as shown in PR25104. The second part of
the patch changes this ice-on-valid to reject-valid for now.
2007-07-22 Daniel Franke <franke.daniel@gmail.com>
PR fortran/25104
PR fortran/31639
* expr.c(check_transformational): Reject valid transformational
intrinsics to avoid ICE.
(check_inquiry): Report error for assumed character lengths for
all supported standards.
2007-07-22 Daniel Franke <franke.daniel@gmail.com>
PR fortran/31639
* gfortran.dg/initialization_9.f90: New test.
Regression tested on i686-pc-linux-gnu. Ok for trunk?
Regards
Daniel
Index: fortran/expr.c
===================================================================
--- fortran/expr.c (revision 126826)
+++ fortran/expr.c (working copy)
@@ -1966,9 +1966,8 @@
&& ap->expr->symtree->n.sym->ts.type == BT_CHARACTER
&& ap->expr->symtree->n.sym->ts.cl->length == NULL)
{
- if (gfc_notify_std (GFC_STD_GNU, "assumed character length "
- "variable '%s' in constant expression at %L",
- e->symtree->n.sym->name, &e->where) == FAILURE)
+ gfc_error ("assumed character length variable '%s' in constant "
+ "expression at %L", e->symtree->n.sym->name, &e->where);
return MATCH_ERROR;
}
else if (not_restricted && check_init_expr (ap->expr) == FAILURE)
@@ -2007,11 +2006,23 @@
if (strcmp (trans_func_f95[i], name) == 0)
break;
+ /* FIXME, F2003: implement translation of initialization
+ expressions before enabling this check. For F95, error
+ out if the transformational function is not in the list. */
+#if 0
if (trans_func_f95[i] == NULL
&& gfc_notify_std (GFC_STD_F2003,
"transformational intrinsic '%s' at %L is not permitted "
"in an initialization expression", name, &e->where) == FAILURE)
return MATCH_ERROR;
+#else
+ if (trans_func_f95[i] == NULL)
+ {
+ gfc_error("transformational intrinsic '%s' at %L is not permitted "
+ "in an initialization expression", name, &e->where);
+ return MATCH_ERROR;
+ }
+#endif
return check_init_expr_arguments (e);
}
Index: testsuite/gfortran.dg/initialization_9.f90
===================================================================
--- testsuite/gfortran.dg/initialization_9.f90 (revision 0)
+++ testsuite/gfortran.dg/initialization_9.f90 (revision 0)
@@ -0,0 +1,11 @@
+! { dg-do compile }
+!
+! PR fortran/31639
+! Contributed by Martin Michlmayr <tbm >T cyrius DOT com>
+
+ integer function xstrcmp(s1)
+ character*(*), intent(in) :: s1
+ integer :: n1 = len(s1) ! { dg-error "assumed character length variable" }
+ n1 = 1
+ return
+ end function xstrcmp