diff mbox series

PR fortran/91802 -- rank+corank must be less than 16

Message ID 20190924224906.GA53331@troutmask.apl.washington.edu
State New
Headers show
Series PR fortran/91802 -- rank+corank must be less than 16 | expand

Commit Message

Steve Kargl Sept. 24, 2019, 10:49 p.m. UTC
The attached patch has been tested on x86_64-*-freebsd.  OK to commit?

2019-09-24  Steven G. Kargl  <kargl@gcc.ngu.org>

	PR fortran/91802
	* decl.c (attr_decl1): Check if rank+corank > 15.

2019-09-24  Steven G. Kargl  <kargl@gcc.ngu.org>

	PR fortran/91802
	* gfortran.dg/pr91802.f90: New test.

Comments

Steve Kargl Sept. 28, 2019, 5:11 p.m. UTC | #1
Committed as r276254.
Jerry DeLisle Sept. 28, 2019, 8:13 p.m. UTC | #2
On 9/28/19 10:11 AM, Steve Kargl wrote:
> Committed as r276254.
> 

I am getting this:

gfc -c -fcoarray=single pr91802.f90
f951: internal compiler error: free_expr0(): Bad expr type
0x809fc9 gfc_report_diagnostic
	../../trunk/gcc/fortran/error.c:776
0x80b62a gfc_internal_error(char const*, ...)
...

I will do a rebuild and rerun in case I missed something.

This is on x86_64-pc-linux-gnu.

Jerry
Steve Kargl Sept. 28, 2019, 10:06 p.m. UTC | #3
On Sat, Sep 28, 2019 at 01:13:42PM -0700, Jerry DeLisle wrote:
> On 9/28/19 10:11 AM, Steve Kargl wrote:
> > Committed as r276254.
> > 
> 
> I am getting this:
> 
> gfc -c -fcoarray=single pr91802.f90
> f951: internal compiler error: free_expr0(): Bad expr type
> 0x809fc9 gfc_report_diagnostic
> 	../../trunk/gcc/fortran/error.c:776
> 0x80b62a gfc_internal_error(char const*, ...)
> ...
> 
> I will do a rebuild and rerun in case I missed something.
> 

Bummer.  May be due to difference with --enable-checking.
Steve Kargl Sept. 29, 2019, 2:08 a.m. UTC | #4
On Sat, Sep 28, 2019 at 03:06:13PM -0700, Steve Kargl wrote:
> On Sat, Sep 28, 2019 at 01:13:42PM -0700, Jerry DeLisle wrote:
> > On 9/28/19 10:11 AM, Steve Kargl wrote:
> > > Committed as r276254.
> > > 
> > 
> > I am getting this:
> > 
> > gfc -c -fcoarray=single pr91802.f90
> > f951: internal compiler error: free_expr0(): Bad expr type
> > 0x809fc9 gfc_report_diagnostic
> > 	../../trunk/gcc/fortran/error.c:776
> > 0x80b62a gfc_internal_error(char const*, ...)
> > ...
> > 
> > I will do a rebuild and rerun in case I missed something.
> > 
> 
> Bummer.  May be due to difference with --enable-checking.
> 

Just bootstrapped trunk in an empty directory.  No issue.

If it persists for you, you can chnage the 'goto cleanup'
in the original patch to 'return m'.  gfortran is exiting,
so leaking memory isn't a concern.
diff mbox series

Patch

Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c	(revision 275969)
+++ gcc/fortran/decl.c	(working copy)
@@ -8468,6 +8468,15 @@  attr_decl1 (void)
       goto cleanup;
     }
 
+  /* Check F2018:C822.  */
+  if (sym->attr.dimension && sym->attr.codimension
+      && sym->as && sym->as->rank + sym->as->corank > 15)
+    {
+      gfc_error ("rank + corank of %qs exceeds 15 at %C", sym->name);
+      m = MATCH_ERROR;
+      goto cleanup;
+    }
+
   if (sym->attr.cray_pointee && sym->as != NULL)
     {
       /* Fix the array spec.  */
Index: gcc/testsuite/gfortran.dg/pr91802.f90
===================================================================
--- gcc/testsuite/gfortran.dg/pr91802.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr91802.f90	(working copy)
@@ -0,0 +1,9 @@ 
+! { dg-do compile }
+! { dg-options "-fcoarray=single" }
+! Code contributed by Gerhard Steinmetz
+! PR fortran/91802
+module m
+   real :: x
+   dimension ::   x(1,2,1,2,1,2,1,2)
+   codimension :: x[1,2,1,2,1,2,1,*] ! { dg-error "exceeds 15" }
+end