This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] fortran/67758 -- Prevent ICE caused by misplaced COMMON
- From: Mikael Morin <mikael dot morin at sfr dot fr>
- To: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- Cc: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Fri, 2 Oct 2015 11:28:06 +0200
- Subject: Re: [PATCH] fortran/67758 -- Prevent ICE caused by misplaced COMMON
- Authentication-results: sourceware.org; auth=none
- Authentication-results: sfrmc.priv.atos.fr; dkim=none (no signature); dkim-adsp=none (no policy) header dot from=mikael dot morin at sfr dot fr
- References: <20151001000630 dot GB73614 at troutmask dot apl dot washington dot edu> <20151001000740 dot GC73614 at troutmask dot apl dot washington dot edu> <560D240C dot 5070405 at sfr dot fr> <560D3521 dot 5050406 at sfr dot fr> <20151001163040 dot GA77294 at troutmask dot apl dot washington dot edu>
Le 01/10/2015 18:30, Steve Kargl a Ãcrit :
I'm fine with your patch, although I find the error message
to be somewhat confusing as no procedure appears in COMMON.
Well, XX is implicitly a procedure.
The call-stmt in the code is the start of an execution-construct.
A common-stmt is not allowed in an execution-construct. At
least, that's how I intepret the BNF in 2.1 of F2008.
The error message appears too soon, before we finish parsing the common
statement. If it's delayed, as with the following additional patch, the
common statements is properly rejected:
common_24.f:10:72:
COMMON /FMCOM / XX(80 000 000) ! { dg-error "conflicts with
COMMON" }
1
Error: Unexpected COMMON statement at (1)
common_24.f:8:72:
Error: PROCEDURE attribute conflicts with COMMON attribute in âxxâ at (1)
This needs a little more polishing (location missing in the second error
message), then let's see how the testsuite likes it.
Mikael
Index: match.c
===================================================================
--- match.c (rÃvision 228170)
+++ match.c (copie de travail)
@@ -4376,9 +4376,6 @@ gfc_match_common (void)
goto cleanup;
}
- if (!gfc_add_in_common (&sym->attr, sym->name, NULL))
- goto cleanup;
-
if (tail != NULL)
tail->common_next = sym;
else
Index: resolve.c
===================================================================
--- resolve.c (rÃvision 228170)
+++ resolve.c (copie de travail)
@@ -918,6 +918,9 @@ resolve_common_vars (gfc_symbol *sym, bool named_c
for (; csym; csym = csym->common_next)
{
+ if (!gfc_add_in_common (&csym->attr, csym->name, NULL))
+ continue;
+
if (csym->value || csym->attr.data)
{
if (!csym->ns->is_block_data)