public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/46122] New: PROTECTED check too strict
@ 2010-10-21 21:20 burnus at gcc dot gnu.org
  2010-10-21 21:42 ` [Bug fortran/46122] " burnus at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2010-10-21 21:20 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: PROTECTED check too strict
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: burnus@gcc.gnu.org


gfortran rejects valid
  <protected_pointer>%<component>
references, cf. "OK 3" and "OK 4" below.

The test case was created by Jared Ahern and the issue was reported to
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/6a866eb893ad8473

Note: The OK/Invalid lines are according to my understanding; no guarantee that
those are correct.


MODULE amod
   IMPLICIT NONE
   TYPE foo
      INTEGER :: i = 4
      INTEGER, POINTER :: j => NULL()
   END TYPE foo
   TYPE(foo), SAVE, PROTECTED :: a
   TYPE(foo), SAVE, PROTECTED, POINTER :: b
   INTEGER, SAVE, PROTECTED :: i = 5
   INTEGER, SAVE, PROTECTED, POINTER :: j => NULL()
contains
  subroutine alloc()
    allocate(b,j)
  end subroutine alloc
END MODULE amod

PROGRAM test
   USE amod
   IMPLICIT NONE
   INTEGER, TARGET :: k
   TYPE(foo), TARGET :: c
   k = 2   ! local
   c%i = 9 ! local

   call alloc()

   ! In parentheses: compiler gives error for that line
   ! gfortran 4.6/Oct, g95 Aug 2010, NAG 5.1, ifort 11.1,
   ! pathf95 3.2.99, PGI 10.5 (compiles without error), crayftn 
   i = k    ! Invalid 1  (gfortran  NAG  g95  ifort  pathf95  cray)
   j => k   ! Invalid 2  (gfortran       g95  ifort  pathf95  cray)
   j = 3    ! OK 1       (                    ifort  pathf95  cray)
   a = c    ! Invalid 3  (gfortran  NAG  g95  ifort  pathf95  cray)
   a%i = k  ! Invalid 4  (gfortran  NAG  g95  ifort  pathf95  cray)
   a%j => k ! Invalid 5  (gfortran  NAG  g95  ifort  pathf95  cray)
   a%j = 5  ! OK 2       (               g95  ifort  pathf95  cray)
   b => c   ! Invalid 6  (gfortran       g95  ifort  pathf95  cray)
   b%i = k  ! OK 3       (gfortran            ifort   [bug]   cray)
   b%j => k ! OK 4       (gfortran       g95  ifort   [bug]   cray)
   b%j = 5  ! OK 5       (                    ifort   [bug]   cray)

END PROGRAM test


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

* [Bug fortran/46122] PROTECTED check too strict
  2010-10-21 21:20 [Bug fortran/46122] New: PROTECTED check too strict burnus at gcc dot gnu.org
@ 2010-10-21 21:42 ` burnus at gcc dot gnu.org
  2010-10-22 10:44 ` domob at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2010-10-21 21:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |domob at gcc dot gnu.org

--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2010-10-21 21:41:52 UTC ---
Untested patch.

Daniel, what do you think? Is such a check also needed elsewhere in
gfc_check_vardef_context (e.g. for the PURE check)?

--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -4400,7 +4400,7 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer,
const char* context)
     }

   /* PROTECTED and use-associated.  */
-  if (sym->attr.is_protected && sym->attr.use_assoc)
+  if (sym->attr.is_protected && sym->attr.use_assoc && check_intentin)
     {
       if (pointer && is_pointer)
        {


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

* [Bug fortran/46122] PROTECTED check too strict
  2010-10-21 21:20 [Bug fortran/46122] New: PROTECTED check too strict burnus at gcc dot gnu.org
  2010-10-21 21:42 ` [Bug fortran/46122] " burnus at gcc dot gnu.org
@ 2010-10-22 10:44 ` domob at gcc dot gnu.org
  2010-10-23 13:48 ` burnus at gcc dot gnu.org
  2010-10-23 13:49 ` burnus at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: domob at gcc dot gnu.org @ 2010-10-22 10:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Daniel Kraft <domob at gcc dot gnu.org> 2010-10-22 10:44:16 UTC ---
I have to admit that I more or less copied that "check_intentin" business while
rewriting the code.  It seems to "make sense", but I didn't find (and care to
find) this in the standard.  So if you think that this is the correct behaviour
also for PROTECTED, then I think this patch is what we want.  But whether this
is correct or we even should do that for PURE is something I have no idea
about.


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

* [Bug fortran/46122] PROTECTED check too strict
  2010-10-21 21:20 [Bug fortran/46122] New: PROTECTED check too strict burnus at gcc dot gnu.org
  2010-10-21 21:42 ` [Bug fortran/46122] " burnus at gcc dot gnu.org
  2010-10-22 10:44 ` domob at gcc dot gnu.org
@ 2010-10-23 13:48 ` burnus at gcc dot gnu.org
  2010-10-23 13:49 ` burnus at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2010-10-23 13:48 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2010-10-23 13:48:12 UTC ---
Author: burnus
Date: Sat Oct 23 13:48:08 2010
New Revision: 165883

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=165883
Log:
2010-10-23  Tobias Burnus  <burnus@net-b.de>

        PR fortran/46122
        * expr.c (gfc_check_vardef_context): Fix PROTECTED check.

2010-10-23  Tobias Burnus  <burnus@net-b.de>

        PR fortran/46122
        * gfortran.dg/protected_8.f90: New.


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


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

* [Bug fortran/46122] PROTECTED check too strict
  2010-10-21 21:20 [Bug fortran/46122] New: PROTECTED check too strict burnus at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2010-10-23 13:48 ` burnus at gcc dot gnu.org
@ 2010-10-23 13:49 ` burnus at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2010-10-23 13:49 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2010-10-23 13:49:05 UTC ---
FIXED on the trunk (4.6).


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

end of thread, other threads:[~2010-10-23 13:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-21 21:20 [Bug fortran/46122] New: PROTECTED check too strict burnus at gcc dot gnu.org
2010-10-21 21:42 ` [Bug fortran/46122] " burnus at gcc dot gnu.org
2010-10-22 10:44 ` domob at gcc dot gnu.org
2010-10-23 13:48 ` burnus at gcc dot gnu.org
2010-10-23 13:49 ` 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).