This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch, fortran] PR31251 Non-integer character length leads to segfault
- 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: Sat, 05 May 2007 10:39:57 -0700
- Subject: [patch, fortran] PR31251 Non-integer character length leads to segfault
:ADDPATCH fortran:
This is the second half of the fix for this bug. The first half fixed the
segfault problem. This patch fixes the double error message.
It turns out that since the character specification was being matched for both a
function prefix and a variable declaration, a character length was being added
to the cl_list for both times. The error in the character length was then
getting issued when cl_list is resolved, giving two error messages.
To fix this, I placed a check in decl.c (match_char_spec) to issue the error and
exit before the bogus lengths are added to cl_list.
Bootstrapped on latest trunk and passes regression testing on x86-64-gnu-linux.
I will make a test case as appropriate.
OK for trunk?
Jerry
2007-05-05 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR fortran/31251
* decl.c (match_char_spec): Add check for invalid character lengths.
Index: decl.c
===================================================================
*** decl.c (revision 124460)
--- decl.c (working copy)
*************** done:
*** 1634,1639 ****
--- 1634,1646 ----
m = MATCH_ERROR;
}
+ if (m == MATCH_YES && seen_length == 1 && len != NULL
+ && len->ts.type != BT_INTEGER && len->ts.type != BT_UNKNOWN)
+ {
+ gfc_error ("Expression at %C must be of INTEGER type");
+ m = MATCH_ERROR;
+ }
+
if (m != MATCH_YES)
{
gfc_free_expr (len);
character(len=2.3) :: s
print *, len(s)
end