public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/51502] New: [4.6/4.7 Regression] Potentially wrong code due to wrong implict_pure check
@ 2011-12-11 17:15 burnus at gcc dot gnu.org
  2011-12-11 17:43 ` [Bug fortran/51502] [4.6/4.7 Regression] Potentially wrong code generation " burnus at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-12-11 17:15 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51502

             Bug #: 51502
           Summary: [4.6/4.7 Regression] Potentially wrong code due to
                    wrong implict_pure check
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org


The following code has a procedure which is not PURE as it accesses a
host-associated variable. However, this is not detected and thus the procedure
is marked as IMPLICIT_PURE as "grep _PURE m.mod" shows:
  0 0 SUBROUTINE IMPLICIT_PURE) (UNKNOWN 0 0 0 0 UNKNOWN ()) 3 0 (4) () 0


module m
  integer :: i
contains
  subroutine foo(x)
    integer, intent(inout) :: x
    outer: block
      block
        i = 5
      end block
    end block outer
  end subroutine foo
end module m


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

* [Bug fortran/51502] [4.6/4.7 Regression] Potentially wrong code generation due to wrong implict_pure check
  2011-12-11 17:15 [Bug fortran/51502] New: [4.6/4.7 Regression] Potentially wrong code due to wrong implict_pure check burnus at gcc dot gnu.org
@ 2011-12-11 17:43 ` burnus at gcc dot gnu.org
  2011-12-11 20:36 ` tkoenig at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: burnus at gcc dot gnu.org @ 2011-12-11 17:43 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51502

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.6.3
            Summary|[4.6/4.7 Regression]        |[4.6/4.7 Regression]
                   |Potentially wrong code due  |Potentially wrong code
                   |to wrong implict_pure check |generation due to wrong
                   |                            |implict_pure check


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

* [Bug fortran/51502] [4.6/4.7 Regression] Potentially wrong code generation due to wrong implict_pure check
  2011-12-11 17:15 [Bug fortran/51502] New: [4.6/4.7 Regression] Potentially wrong code due to wrong implict_pure check burnus at gcc dot gnu.org
  2011-12-11 17:43 ` [Bug fortran/51502] [4.6/4.7 Regression] Potentially wrong code generation " burnus at gcc dot gnu.org
@ 2011-12-11 20:36 ` tkoenig at gcc dot gnu.org
  2011-12-11 21:01 ` tkoenig at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2011-12-11 20:36 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51502

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2011-12-11
                 CC|                            |tkoenig at gcc dot gnu.org
     Ever Confirmed|0                           |1

--- Comment #1 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2011-12-11 20:29:39 UTC ---
Nitpick: A pure procedure could access the variable, but
it could assign a value to it.

Because

module m
  integer :: i
contains
  pure subroutine foo(x)
    integer, intent(inout) :: x
    outer: block
      block
        i = 5
      end block
    end block outer
  end subroutine foo
end module m

gives the error

Error: Variable 'i' can not appear in a variable definition context
(assignment) at (1) in PURE procedure

the fix should be straightforward.


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

* [Bug fortran/51502] [4.6/4.7 Regression] Potentially wrong code generation due to wrong implict_pure check
  2011-12-11 17:15 [Bug fortran/51502] New: [4.6/4.7 Regression] Potentially wrong code due to wrong implict_pure check burnus at gcc dot gnu.org
  2011-12-11 17:43 ` [Bug fortran/51502] [4.6/4.7 Regression] Potentially wrong code generation " burnus at gcc dot gnu.org
  2011-12-11 20:36 ` tkoenig at gcc dot gnu.org
@ 2011-12-11 21:01 ` tkoenig at gcc dot gnu.org
  2011-12-12  8:20 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2011-12-11 21:01 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51502

--- Comment #2 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2011-12-11 20:56:54 UTC ---
The problem occurs in expr.c:


  if (!pointer && gfc_implicit_pure (NULL) && gfc_impure_variable (sym))
    gfc_current_ns->proc_name->attr.implicit_pure = 0;

assumes that gfc_current_ns points to the current procedure, which
is wrong in the case of blocks.

Maybe it would make sense to have a global gfc_proc_name?

Also, the logic in gfc_implicit_pure() appears to be wrong
because it does not look for parent namespaces.


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

* [Bug fortran/51502] [4.6/4.7 Regression] Potentially wrong code generation due to wrong implict_pure check
  2011-12-11 17:15 [Bug fortran/51502] New: [4.6/4.7 Regression] Potentially wrong code due to wrong implict_pure check burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2011-12-11 21:01 ` tkoenig at gcc dot gnu.org
@ 2011-12-12  8:20 ` jakub at gcc dot gnu.org
  2011-12-28 22:52 ` tkoenig at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: jakub at gcc dot gnu.org @ 2011-12-12  8:20 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51502

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P4
                 CC|                            |jakub at gcc dot gnu.org


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

* [Bug fortran/51502] [4.6/4.7 Regression] Potentially wrong code generation due to wrong implict_pure check
  2011-12-11 17:15 [Bug fortran/51502] New: [4.6/4.7 Regression] Potentially wrong code due to wrong implict_pure check burnus at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2011-12-12  8:20 ` jakub at gcc dot gnu.org
@ 2011-12-28 22:52 ` tkoenig at gcc dot gnu.org
  2011-12-31  8:50 ` tkoenig at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2011-12-28 22:52 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51502

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
         AssignedTo|unassigned at gcc dot       |tkoenig at gcc dot gnu.org
                   |gnu.org                     |


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

* [Bug fortran/51502] [4.6/4.7 Regression] Potentially wrong code generation due to wrong implict_pure check
  2011-12-11 17:15 [Bug fortran/51502] New: [4.6/4.7 Regression] Potentially wrong code due to wrong implict_pure check burnus at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2011-12-28 22:52 ` tkoenig at gcc dot gnu.org
@ 2011-12-31  8:50 ` tkoenig at gcc dot gnu.org
  2012-01-01 16:13 ` tkoenig at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2011-12-31  8:50 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51502

--- Comment #3 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2011-12-31 08:19:01 UTC ---
Author: tkoenig
Date: Sat Dec 31 08:18:52 2011
New Revision: 182754

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182754
Log:
2011-12-31  Thomas König  <tkoenig@gcc.gnu.org>

    PR fortran/51502
    * expr.c (gfc_check_vardef_context):  When determining
    implicit pure status, also check for variable definition
    context.  Walk up namespaces until a procedure is
    found to reset the implict pure attribute.
    * resolve.c (gfc_implicit_pure):  Walk up namespaces
    until a procedure is found.

2011-12-31  Thomas König  <tkoenig@gcc.gnu.org>

    PR fortran/51502
    * lib/gcc-dg.exp (scan-module-absence):  New function.
    * gfortran.dg/implicit_pure_2.f90:  New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/implicit_pure_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/expr.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug fortran/51502] [4.6/4.7 Regression] Potentially wrong code generation due to wrong implict_pure check
  2011-12-11 17:15 [Bug fortran/51502] New: [4.6/4.7 Regression] Potentially wrong code due to wrong implict_pure check burnus at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2011-12-31  8:50 ` tkoenig at gcc dot gnu.org
@ 2012-01-01 16:13 ` tkoenig at gcc dot gnu.org
  2012-01-01 16:14 ` tkoenig at gcc dot gnu.org
  2012-01-01 16:28 ` tkoenig at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2012-01-01 16:13 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51502

--- Comment #4 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2012-01-01 16:12:50 UTC ---
Author: tkoenig
Date: Sun Jan  1 16:12:39 2012
New Revision: 182770

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182770
Log:
2012-01-01  Thomas König  <tkoenig@gcc.gnu.org>

    Backport from trunk
    PR fortran/51502
    * expr.c (gfc_check_vardef_context):  When determining
    implicit pure status, also check for variable definition
    context.  Walk up namespaces until a procedure is
    found to reset the implict pure attribute.
    * resolve.c (gfc_implicit_pure):  Walk up namespaces
    until a procedure is found.

2012-01-01  Thomas König  <tkoenig@gcc.gnu.org>

    Backport from trunk
    PR fortran/51502
    * lib/gcc-dg.exp (scan-module-absence):  New function.
    * gfortran.dg/implicit_pure_2.f90:  New test.


Added:
    branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/implicit_pure_2.f90
Modified:
    branches/gcc-4_6-branch/gcc/fortran/ChangeLog
    branches/gcc-4_6-branch/gcc/fortran/expr.c
    branches/gcc-4_6-branch/gcc/fortran/resolve.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_6-branch/gcc/testsuite/lib/gcc-dg.exp


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

* [Bug fortran/51502] [4.6/4.7 Regression] Potentially wrong code generation due to wrong implict_pure check
  2011-12-11 17:15 [Bug fortran/51502] New: [4.6/4.7 Regression] Potentially wrong code due to wrong implict_pure check burnus at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2012-01-01 16:13 ` tkoenig at gcc dot gnu.org
@ 2012-01-01 16:14 ` tkoenig at gcc dot gnu.org
  2012-01-01 16:28 ` tkoenig at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2012-01-01 16:14 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51502

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #5 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2012-01-01 16:13:27 UTC ---
Fixed on trunk and 4.6, closing.


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

* [Bug fortran/51502] [4.6/4.7 Regression] Potentially wrong code generation due to wrong implict_pure check
  2011-12-11 17:15 [Bug fortran/51502] New: [4.6/4.7 Regression] Potentially wrong code due to wrong implict_pure check burnus at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2012-01-01 16:14 ` tkoenig at gcc dot gnu.org
@ 2012-01-01 16:28 ` tkoenig at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2012-01-01 16:28 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51502

--- Comment #6 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2012-01-01 16:27:53 UTC ---
Author: tkoenig
Date: Sun Jan  1 16:27:45 2012
New Revision: 182771

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182771
Log:
2012-01-01  Thomas König  <tkoenig@gcc.gnu.org>

    Backport from trunk
    PR fortran/51502
    * lib/gcc-dg.exp (scan-module-absence):  New function.
    * gfortran.dg/implicit_pure_2.f90:  New test.



Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/lib/gcc-dg.exp


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

end of thread, other threads:[~2012-01-01 16:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-11 17:15 [Bug fortran/51502] New: [4.6/4.7 Regression] Potentially wrong code due to wrong implict_pure check burnus at gcc dot gnu.org
2011-12-11 17:43 ` [Bug fortran/51502] [4.6/4.7 Regression] Potentially wrong code generation " burnus at gcc dot gnu.org
2011-12-11 20:36 ` tkoenig at gcc dot gnu.org
2011-12-11 21:01 ` tkoenig at gcc dot gnu.org
2011-12-12  8:20 ` jakub at gcc dot gnu.org
2011-12-28 22:52 ` tkoenig at gcc dot gnu.org
2011-12-31  8:50 ` tkoenig at gcc dot gnu.org
2012-01-01 16:13 ` tkoenig at gcc dot gnu.org
2012-01-01 16:14 ` tkoenig at gcc dot gnu.org
2012-01-01 16:28 ` tkoenig 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).