diff mbox series

[fortran] PR36497 - USE association, cray pointers and error checking

Message ID CAGkQGiJE=wKFbAqpAsvBg365Rv8YgquTW1oU2R_r1Hm1JOtX_g@mail.gmail.com
State New
Headers show
Series [fortran] PR36497 - USE association, cray pointers and error checking | expand

Commit Message

Paul Richard Thomas June 3, 2018, 8:29 a.m. UTC
I was going to commit this as obvious but GNU-central seems to be
down. I will do so when I can.

I only intend to apply it to trunk since it has been around since
2008-06-11 without any clamor to fix it :-) I don't recall why I took
it on in the first place.

Cheers

Paul

2018-06-03  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/36497
    * decl.c (variable_decl): Use gfc_add_type for cray pointees.

2018-06-03  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/36497

    * gfortran.dg/cray_pointer_12.f90: New test.

Comments

Paul Richard Thomas June 3, 2018, 11:24 a.m. UTC | #1
Committed as revision 261127. The PR is closed.

The permissions of my ssh keys were changed by a system update; hence
the difficulties with updating my tree.

Paul

On 3 June 2018 at 09:29, Paul Richard Thomas
<paul.richard.thomas@gmail.com> wrote:
> I was going to commit this as obvious but GNU-central seems to be
> down. I will do so when I can.
>
> I only intend to apply it to trunk since it has been around since
> 2008-06-11 without any clamor to fix it :-) I don't recall why I took
> it on in the first place.
>
> Cheers
>
> Paul
>
> 2018-06-03  Paul Thomas  <pault@gcc.gnu.org>
>
>     PR fortran/36497
>     * decl.c (variable_decl): Use gfc_add_type for cray pointees.
>
> 2018-06-03  Paul Thomas  <pault@gcc.gnu.org>
>
>     PR fortran/36497
>
>     * gfortran.dg/cray_pointer_12.f90: New test.
diff mbox series

Patch

Index: gcc/fortran/decl.c
===================================================================
*** gcc/fortran/decl.c	(revision 260412)
--- gcc/fortran/decl.c	(working copy)
*************** variable_decl (int elem)
*** 2418,2424 ****
  	    }
  
  	  if (not_constant)
! 	    { 
  	      gfc_error ("Explicit shaped array with nonconstant bounds at %C");
  	      m = MATCH_ERROR;
  	      goto cleanup;
--- 2418,2424 ----
  	    }
  
  	  if (not_constant)
! 	    {
  	      gfc_error ("Explicit shaped array with nonconstant bounds at %C");
  	      m = MATCH_ERROR;
  	      goto cleanup;
*************** variable_decl (int elem)
*** 2522,2534 ****
        gfc_find_symbol (name, gfc_current_ns, 1, &sym);
        if (sym != NULL && sym->attr.cray_pointee)
  	{
- 	  sym->ts.type = current_ts.type;
- 	  sym->ts.kind = current_ts.kind;
- 	  sym->ts.u.cl = cl;
- 	  sym->ts.u.derived = current_ts.u.derived;
- 	  sym->ts.is_c_interop = current_ts.is_c_interop;
- 	  sym->ts.is_iso_c = current_ts.is_iso_c;
  	  m = MATCH_YES;
  
  	  /* Check to see if we have an array specification.  */
  	  if (cp_as != NULL)
--- 2522,2533 ----
        gfc_find_symbol (name, gfc_current_ns, 1, &sym);
        if (sym != NULL && sym->attr.cray_pointee)
  	{
  	  m = MATCH_YES;
+ 	  if (!gfc_add_type (sym, &current_ts, &gfc_current_locus))
+ 	    {
+ 	      m = MATCH_ERROR;
+ 	      goto cleanup;
+ 	    }
  
  	  /* Check to see if we have an array specification.  */
  	  if (cp_as != NULL)
Index: gcc/testsuite/gfortran.dg/cray_pointers_12.f90
===================================================================
*** gcc/testsuite/gfortran.dg/cray_pointers_12.f90	(nonexistent)
--- gcc/testsuite/gfortran.dg/cray_pointers_12.f90	(working copy)
***************
*** 0 ****
--- 1,23 ----
+ ! { dg-do compile }
+ ! { dg-options "-fcray-pointer" }
+ !
+ ! Test the fix for PR36497 in which there was no error for the second
+ ! declaration of 'x'.
+ !
+ ! Contributed by Tobias Burnus  <burnus@gcc.gnu.org>
+ !
+ module test
+  integer(8) ipt
+  integer z(2), x
+  pointer (ipt, x)
+ end module
+ 
+ program bar
+  use test   ! { dg-error "conflicts with symbol" }
+  integer x  ! { dg-error "conflicts with symbol" }
+  ipt = loc(z(1))
+  x = 1
+  ipt = loc(z(2))
+  x = 3
+  if (any (z .ne. [1,3])) stop 1
+ end