Le 01/10/2015 14:16, Mikael Morin a écrit :
Le 01/10/2015 02:07, Steve Kargl a écrit :
On Wed, Sep 30, 2015 at 05:06:30PM -0700, Steve Kargl wrote:
Patch built and regression tested on x86_64-*-freebsd.
OK to commit?
The patch prevents the dereferencing of a NULL pointer
by jumping out of the cleanup of a list of COMMON blocks.
Hold on, I believe p should be present in the common symbol list pointed
by p->common.
s/p->common/p->common_block/
And by the way, if we are in gfc_restore_last_undo_checkpoint, we have
found something bogus enough to backtrack, so hopefully an error has
already been prepared (but maybe not emitted).
I will investigate more.
It seems the error [1] is reported in gfc_add_in_common, between the
time the symbol's common_block pointer is set and the time the symbol is
added to the list.
As the program goes straight to clean-up/return upon error, this interim
state is not fixed and poses problem.
So we need to reduce the interim time to zero or fix the state upon error.
I propose the following, which delays setting the common_block after
error_checking (I believe it is not used in that time).
Regression-tested on x86_64-unknown-linux-gnu. OK for trunk?
Mikael
[1] Error: PROCEDURE attribute conflicts with COMMON attribute in 'xx'
at (1)
2015-10-01 Mikael Morin <mik...@gcc.gnu.org>
PR fortran/67758
* match.c (gfc_match_common): Delay the common_block pointer
assignment after error checking.
2015-10-01 Mikael Morin <mik...@gcc.gnu.org>
PR fortran/67758
* gfortran.dg/common_24.f: New.
Index: match.c
===================================================================
--- match.c (révision 228170)
+++ match.c (copie de travail)
@@ -4330,10 +4330,6 @@ gfc_match_common (void)
if (m == MATCH_NO)
goto syntax;
- /* Store a ref to the common block for error checking. */
- sym->common_block = t;
- sym->common_block->refs++;
-
/* See if we know the current common block is bind(c), and if
so, then see if we can check if the symbol is (which it'll
need to be). This can happen if the bind(c) attr stmt was
@@ -4379,6 +4375,10 @@ gfc_match_common (void)
if (!gfc_add_in_common (&sym->attr, sym->name, NULL))
goto cleanup;
+ /* Store a ref to the common block for error checking. */
+ sym->common_block = t;
+ sym->common_block->refs++;
+
if (tail != NULL)
tail->common_next = sym;
else
c { dg-do compile }
c PR fortran/67758
c
c Check the absence of ICE after emitting the error message
c
c Contributed by Ilya Enkovich <ienkov...@gcc.gnu.org>
COMMON /FMCOM / X(80 000 000)
CALL T(XX(A))
COMMON /FMCOM / XX(80 000 000) ! { dg-error "conflicts with COMMON" }
END