re PR fortran/36497 (USE association, cray pointers and error checking)
authorPaul Thomas <pault@gcc.gnu.org>
Sun, 3 Jun 2018 11:14:51 +0000 (11:14 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Sun, 3 Jun 2018 11:14:51 +0000 (11:14 +0000)
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.

From-SVN: r261127

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/cray_pointers_12.f90 [new file with mode: 0644]

index 272a94eadc360b11f5c97c33cf1a09fc13952057..ef7e941fd660686437205e25e51c3ace78c38a58 100644 (file)
@@ -1,10 +1,15 @@
+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-01  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/63570
        * check.c (gfc_check_random_init): New function. Check arguments of
        RANDOM_INIT.
        * gfortran.h (GFC_ISYM_RANDOM_INIT): New enum token.
-       * intrinsic.c (add_subroutines): Add RANDOM_INIT to list of 
+       * intrinsic.c (add_subroutines): Add RANDOM_INIT to list of
        subroutines.
        (gfc_check_intrinsic_standard): Introduce Fortran 2018 check.
        * intrinsic.h: Add prototypes for gfc_check_random_init and
index 2fca8ad1f5dd0ccbb01f1d6375ad82909b88f6e3..df21ce0943b86f3f024a2b1160a90f5e399bf499 100644 (file)
@@ -2431,7 +2431,7 @@ variable_decl (int elem)
            }
 
          if (not_constant)
-           { 
+           {
              gfc_error ("Explicit shaped array with nonconstant bounds at %C");
              m = MATCH_ERROR;
              goto cleanup;
@@ -2535,13 +2535,12 @@ variable_decl (int elem)
       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;
+         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 1d75437eed7fcebaa578b0b52cf89ae3692b3d1b..084c231960e984036f644a33d8aa8951af1763e2 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-03  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/36497
+       * gfortran.dg/cray_pointer_12.f90: New test.
+
 2018-06-02  Steven G. Kargl  <kargl@gcc.gnu.org>
 
        PR fortran/85938
@@ -77,7 +82,7 @@
        * gfortran.dg/pr85975.f90: New test.
 
 2018-06-01  Steven G. Kargl  <kargl@gcc.gnu.org>
+
        PR fortran/63570
        * gfortran.dg/random_init_1.f90: New test.
        * gfortran.dg/random_init_2.f90: New test.
diff --git a/gcc/testsuite/gfortran.dg/cray_pointers_12.f90 b/gcc/testsuite/gfortran.dg/cray_pointers_12.f90
new file mode 100644 (file)
index 0000000..f9d25a9
--- /dev/null
@@ -0,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