This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[patch, fortran] PR31306 ICE with implicit character variables
- From: Jerry DeLisle <jvdelisle at verizon dot net>
- To: Fortran List <fortran at gcc dot gnu dot org>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 19 Oct 2007 22:40:25 -0700
- Subject: [patch, fortran] PR31306 ICE with implicit character variables
:ADDPATCH fortran:
Hi all,
The attached patch fixes this ICE by checking for a conflicting attribute in the
function argument to LEN(). There may be additional checks that could be added
here, but for now this resolves the segmentation fault.
Regression tested on x86-64-Gnu-linux.
New test case provided.
OK for trunk?
Regards,
Jerry
2007-10-19 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/31306
* decl.c (char_len_param_value): Add check for conflicting attributes of
function argument.
! { dg-do compile }
! PR31306 ICE with implicit character variables
! Test case from PR and prepared by Jerry DeLisle <jvdelisle@gcc.gnu.org>
module cyclic
implicit none
contains
function ouch(x,y) ! { dg-error "has no IMPLICIT type" }
implicit character(len(ouch)) (x) ! { dg-error "Conflict in attributes" }
implicit character(len(x)+1) (y)
implicit character(len(y)-1) (o)
intent(in) x,y
character(len(y)-1) ouch
integer i
do i = 1, len(ouch)
ouch(i:i) = achar(ieor(iachar(x(i:i)),iachar(y(i:i)))) ! { dg-error " PROCEDURE attribute conflicts" }
end do
end function ouch
end module cyclic
Index: decl.c
===================================================================
--- decl.c (revision 129496)
+++ decl.c (working copy)
@@ -572,13 +572,32 @@ match_intent_spec (void)
static match
char_len_param_value (gfc_expr **expr)
{
+ match m;
+
if (gfc_match_char ('*') == MATCH_YES)
{
*expr = NULL;
return MATCH_YES;
}
- return gfc_match_expr (expr);
+ m = gfc_match_expr (expr);
+ if (m == MATCH_YES && (*expr)->expr_type == EXPR_FUNCTION)
+ {
+ if ((*expr)->value.function.actual
+ && (*expr)->value.function.actual->expr->symtree)
+ {
+ gfc_expr *e;
+ e = (*expr)->value.function.actual->expr;
+ if (e->symtree->n.sym->attr.flavor == FL_PROCEDURE
+ && e->expr_type == EXPR_VARIABLE)
+ goto syntax;
+ }
+ }
+ return m;
+
+syntax:
+ gfc_error ("Conflict in attributes of function argument at %C");
+ return MATCH_ERROR;
}
Index: ChangeLog
===================================================================
--- ChangeLog (revision 129496)
+++ ChangeLog (working copy)
@@ -1,5 +1,11 @@
2007-10-19 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+ PR fortran/31306
+ * decl.c (char_len_param_value): Add check for conflicting attributes of
+ function argument.
+
+2007-10-19 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
PR fortran/33544
* simplify.c (gfc_simplify_transfer): Only warn for short transfer when
-Wsurprising is given.