[multiple changes]
authorFritz Reese <Reese-Fritz@zai.com>
Wed, 3 Sep 2014 18:50:27 +0000 (18:50 +0000)
committerTobias Burnus <burnus@gcc.gnu.org>
Wed, 3 Sep 2014 18:50:27 +0000 (20:50 +0200)
2014-09-03  Fritz Reese  <Reese-Fritz@zai.com>

        PR fortran/62174
        * decl.c (variable_decl): Don't overwrite typespecs of Cray
        * pointees
        when matching a component declaration.

2014-09-02  Fritz Reese  <Reese-Fritz@zai.com>

        PR fortran/62174
        * gfortran.dg/cray_pointers_11.f90: New.

From-SVN: r214891

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

index 518923baa5f6acb36dfc15cfc8fc30aa449dd77e..9eeb4cf419b761292fa2d34751f12e419e3c1993 100644 (file)
@@ -1,3 +1,9 @@
+2014-09-03  Fritz Reese  <Reese-Fritz@zai.com>
+
+       PR fortran/62174
+       * decl.c (variable_decl): Don't overwrite typespecs of Cray pointees
+       when matching a component declaration.
+
 2014-09-02  Marek Polacek  <polacek@redhat.com>
 
        PR fortran/62270
index 25d92a46d3e94478b569fba2ec7598e59aa4e9f3..e412a8bd07059059c9c7e240934d09787abe728f 100644 (file)
@@ -1904,8 +1904,9 @@ variable_decl (int elem)
     }
 
   /*  If this symbol has already shown up in a Cray Pointer declaration,
+      and this is not a component declaration,
       then we want to set the type & bail out.  */
-  if (gfc_option.flag_cray_pointer)
+  if (gfc_option.flag_cray_pointer && gfc_current_state () != COMP_DERIVED)
     {
       gfc_find_symbol (name, gfc_current_ns, 1, &sym);
       if (sym != NULL && sym->attr.cray_pointee)
index f0bca8f0bc2bdb927e128001c57a06fab12660d1..1312e4ecf56aa407b8ba29d7a333d2f1072f2bce 100644 (file)
@@ -1,3 +1,8 @@
+2014-09-02  Fritz Reese  <Reese-Fritz@zai.com>
+
+       PR fortran/62174
+       * gfortran.dg/cray_pointers_11.f90: New.
+
 2014-09-03  Martin Jambor  <mjambor@suse.cz>
 
        PR ipa/62015
diff --git a/gcc/testsuite/gfortran.dg/cray_pointers_11.f90 b/gcc/testsuite/gfortran.dg/cray_pointers_11.f90
new file mode 100644 (file)
index 0000000..d847676
--- /dev/null
@@ -0,0 +1,22 @@
+! { dg-do compile }
+! { dg-options "-fcray-pointer" }
+!
+! PR fortran/62174
+! Component declarations within derived types would overwrite the typespec of
+! variables with the same name who were Cray pointees.
+implicit none
+
+type t1
+  integer i
+end type t1
+type(t1) x
+
+pointer (x_ptr, x)
+
+type t2
+  real x ! should not overwrite x's type
+end type t2
+
+x%i = 0 ! should see no error here
+
+end