public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/62174] New: Component declarations overwrite types of Cray Pointee variables
@ 2014-08-18 16:56 fritzoreese at gmail dot com
  2014-09-02 11:38 ` [Bug fortran/62174] " dominiq at lps dot ens.fr
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: fritzoreese at gmail dot com @ 2014-08-18 16:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62174

            Bug ID: 62174
           Summary: Component declarations overwrite types of Cray Pointee
                    variables
           Product: gcc
           Version: 4.8.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fritzoreese at gmail dot com

Created attachment 33353
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33353&action=edit
Proposed patch for the described problem

The typespecs for Cray pointees are overwritten by the typespecs of components
with the same name which are declared later.

This problem was introduced with Cray pointer support in 4.1.0 and is present
as far as I can tell up through the current release.

Here is a proposed patch from 4.8.3. The added test case demonstrates the
problem:

diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 4048ac9..7b3c59a 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -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)
diff --git a/gcc/testsuite/gfortran.dg/cray_pointers_10.f90
b/gcc/testsuite/gfortran.dg/cray_pointers_10.f90
new file mode 100644
index 0000000..fcc0132
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/cray_pointers_10.f90
@@ -0,0 +1,22 @@
+! { dg-do compile }
+! { dg-options "-fcray-pointer" }
+!
+! Since the introduction of Cray pointers in 4.1.0 as late as 4.8.3,
+! 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
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 53d2691..8d8f9d5 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,8 @@
+2014-08-18  Fritz Reese  <Reese-Fritz@zai.com>
+
+    * decl.c (variable_decl): Don't overwrite typesepc of Cray pointees
+    when matching a component declaration.
+
 2014-08-17  Tobias Burnus  <burnus@net-b.de>

     * resolve.c (gfc_resolve_finalizers): Ensure that parents are


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/62174] Component declarations overwrite types of Cray Pointee variables
  2014-08-18 16:56 [Bug fortran/62174] New: Component declarations overwrite types of Cray Pointee variables fritzoreese at gmail dot com
@ 2014-09-02 11:38 ` dominiq at lps dot ens.fr
  2014-09-02 17:57 ` fritzoreese at gmail dot com
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: dominiq at lps dot ens.fr @ 2014-09-02 11:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62174

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-09-02
     Ever confirmed|0                           |1

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Confirmed from 4.7 up to trunk (5.0).


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/62174] Component declarations overwrite types of Cray Pointee variables
  2014-08-18 16:56 [Bug fortran/62174] New: Component declarations overwrite types of Cray Pointee variables fritzoreese at gmail dot com
  2014-09-02 11:38 ` [Bug fortran/62174] " dominiq at lps dot ens.fr
@ 2014-09-02 17:57 ` fritzoreese at gmail dot com
  2014-09-03 18:51 ` burnus at gcc dot gnu.org
  2014-09-03 18:52 ` burnus at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: fritzoreese at gmail dot com @ 2014-09-02 17:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62174

--- Comment #3 from Fritz Reese <fritzoreese at gmail dot com> ---
> Patches should go to the gcc-patches at gcc.gnu.org mailing list (and in
> case of Fortran FE patches also CC fortran at gcc.gnu.org ml).  That is
> where patch review happens.

Sorry - submitted to the mailing lists.
https://gcc.gnu.org/ml/gcc-patches/2014-09/msg00175.html
https://gcc.gnu.org/ml/fortran/2014-09/msg00007.html

> For a one-liner change like this, I think you
> don't need Copyright assignment, but if you plan to submit further patches,
> please consider following https://gcc.gnu.org/contribute.html

I am working with my employer now to decide how best to comply with GNU's legal
requirements for future contributions.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/62174] Component declarations overwrite types of Cray Pointee variables
  2014-08-18 16:56 [Bug fortran/62174] New: Component declarations overwrite types of Cray Pointee variables fritzoreese at gmail dot com
  2014-09-02 11:38 ` [Bug fortran/62174] " dominiq at lps dot ens.fr
  2014-09-02 17:57 ` fritzoreese at gmail dot com
@ 2014-09-03 18:51 ` burnus at gcc dot gnu.org
  2014-09-03 18:52 ` burnus at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2014-09-03 18:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62174

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> ---
Author: burnus
Date: Wed Sep  3 18:50:27 2014
New Revision: 214891

URL: https://gcc.gnu.org/viewcvs?rev=214891&root=gcc&view=rev
Log:
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.


Added:
    trunk/gcc/testsuite/gfortran.dg/cray_pointers_11.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/testsuite/ChangeLog


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Bug fortran/62174] Component declarations overwrite types of Cray Pointee variables
  2014-08-18 16:56 [Bug fortran/62174] New: Component declarations overwrite types of Cray Pointee variables fritzoreese at gmail dot com
                   ` (2 preceding siblings ...)
  2014-09-03 18:51 ` burnus at gcc dot gnu.org
@ 2014-09-03 18:52 ` burnus at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2014-09-03 18:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62174

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|NEW                         |RESOLVED
                 CC|                            |burnus at gcc dot gnu.org
         Resolution|---                         |FIXED

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> ---
FIXED on the trunk (i.e. GCC 5).

Thanks for the report, test case and patch!


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-09-03 18:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-18 16:56 [Bug fortran/62174] New: Component declarations overwrite types of Cray Pointee variables fritzoreese at gmail dot com
2014-09-02 11:38 ` [Bug fortran/62174] " dominiq at lps dot ens.fr
2014-09-02 17:57 ` fritzoreese at gmail dot com
2014-09-03 18:51 ` burnus at gcc dot gnu.org
2014-09-03 18:52 ` burnus at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).