This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran,patch] More detailled runtime bounds-checking messages...
- From: FX Coudert <fxcoudert at gmail dot com>
- To: GNU Fortran <fortran at gcc dot gnu dot org>, gcc-patches list <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 10 Aug 2007 00:31:03 +0100
- Subject: [gfortran,patch] More detailled runtime bounds-checking messages...
... including out-of-bounds index and array bounds!
This patch allows us to perform runtime checks with more than a
static failure message: we can now call runtime_error_at with a
printf-like format string and variable arguments. The front-end also
offers variable-args functions to build these function calls, passing
them trees. For example, if we detect that i (which is not a compile-
time constant, but a tree) is lower than 1 and is used as substring
index, we can do:
gfc_trans_runtime_check (condition, &se->pre, locus, "Substring
index (%%ld) is smaller than one", fold_convert
(long_integer_type_node, index));
The only thing is that we need to make sure the trees passed as
arguments have types matching the format string.
So, I used this new functionality in bounds-checking error messages
generated through-out the front-end, as much as possible (which is
almost everywhere). New messages now look like:
At line 6 of file a.f90
Fortran runtime error: Array reference out of bounds for array
'ivec', upper
bound of dimension 1 exceeded, 3 is greater than 2
So now, I'm looking for a review to get this in, and eventually
suggestions to change the wording if deemed inappropriate.
Bootstrapped and regtested (both with and without -fbounds-check) on
x86_64-linux, OK to commit?
FX
:ADDPATCH fortran:
Attachment:
pr31270.ChangeLog
Description: Binary data
Attachment:
pr31270.diff
Description: Binary data