This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran 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...
- Dkim-signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:mime-version:to:message-id:content-type:from:subject:date:x-mailer; b=Mzt9j2t/Lv7ZRFzR5V5TSXZC1h94IIndQe/O57lL7gfTF0Xb+stKf2rtrdG6WFiXbaoS/ssnpVoRFKZRYJlFsW2rZpOxtOhWFXYXi+dBFuDQKYcRVCV96rHAKOc3H/fQuujXCs93A0kWQaMefI6EYHw/RNbP2+L2pDKdIvisbCY=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:mime-version:to:message-id:content-type:from:subject:date:x-mailer; b=O3euC3KuFUA4IY6UCxA9brlcZKONkoBfXtKS7CWyrpJXLTvYJTbWnWxwPUfAqbo7f/RSopNkGdPcRGqbcJzZ3SJLZHsSetpofH0Sv6SIXoM+dd7JSv6hrVQZK14v6p14v3bPUrQ8YnO8dc3kZVUsg5THfNkeho1H1Hv7ckTTs1o=
... 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