This is the mail archive of the
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
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?
2007-05-05 Jerry DeLisle <firstname.lastname@example.org>
* decl.c (match_char_spec): Add check for invalid character lengths.
*** decl.c (revision 124460)
--- decl.c (working copy)
*** 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)
character(len=2.3) :: s
print *, len(s)