This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch, Fortran] PR42484: ICE with -fopenmp


Hi all,

here is my patch for this PR. It took me a while to find the root of
the ICE (for history see the PR log).

The basic problem is that the Fortran front end does not pass the
correct locus to the middle-end, i.e. the loci do not contain the
correct column number, but instead are always placed at the start of
the line. This can lead to problems if things in the middle end rely
on these locations (cf. comment #8 in the PR). In the case at hand,
some GOTO jump was optimized away, so that the non-validity of the
test case could not be detected by the OpenMP checking pass.

To fix the ICE I did two things:

1) Adjust the locus we pass to the middle-end. This happens in
gfc_set_backend_locus (trans.c). For the loci used in the gfortran
front end, loc->lb->location always contains the location which
corresponds to the beginning of the line. So, when passing it to the
middle-end, I add there the column number. This fixes the ICE, since
for a simple one-lined IF statement, it makes the loci of the
condition and the THEN-clause distinguishable in the middle end.

2) To get the correct column number in the OpenMP error message, I
adjusted the locus for simple one-lined IF statements.

This does fix the ICE for -O0 at least. When compiling with
optimization, the ICE still occurs. But this is not a Fortran-specific
problem. It also happens with C code. To fix it, one would probably
have to modify the optimization code in gimplify_cond_expr (and I'm
not sure if one would still get an approval for this, given it is not
a regression).

So, is it ok to commit the Fortran part? The patch was successfully
regtested on x86_64-unknown-linux-gnu.

Cheers,
Janus



gcc/fortran/
2009-12-28 Janus Weil  <janus@gcc.gnu.org>

	PR fortran/42484
	* match.c (gfc_match_if): Adjust locus.
	* trans.c (gfc_set_backend_locus): Pass correct locus to middle end
	(including proper column number).

gcc/testsuite/
2009-12-28  Janus Weil  <janus@gcc.gnu.org>

	PR fortran/42484
	* gfortran.dg/gomp/block-2.f90: New test.

Attachment: pr42484.diff
Description: Binary data

Attachment: block-2.f90
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]