public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/55855] New: incorrect warning with type-bound procedure pointer
@ 2013-01-03 7:29 abensonca at gmail dot com
2013-01-03 9:15 ` [Bug fortran/55855] [OOP] incorrect warning with type-bound procedure on pointer-valued base object janus at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: abensonca at gmail dot com @ 2013-01-03 7:29 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55855
Bug #: 55855
Summary: incorrect warning with type-bound procedure pointer
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: abensonca@gmail.com
The following:
module eventMod
type, public :: event
private
procedure(eventTask ), pointer, public :: task
end type event
abstract interface
logical function eventTask(self)
import event
class(event), intent(in) :: self
end function eventTask
end interface
end module eventMod
program test
use eventMod
implicit none
logical :: r
type(event), pointer :: myEvent
allocate(myEvent)
r=myEvent%task()
end program test
causes the following warning when compiled (with gfortran 4.8.0):
$ gfortran -v
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/home/abenson/Galacticus/Tools/libexec/gcc/x86_64-unknown-
linux-gnu/4.8.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-trunk/configure --
prefix=/home/abenson/Galacticus/Tools --enable-languages=c,c++,fortran --
disable-multilib --with-gmp=/home/abenson/Galacticus/Tools
Thread model: posix
gcc version 4.8.0 20121219 (experimental) (GCC)
$ gfortran -o warn.exe warn.F90 -Wall
warn.F90:19.4:
r=myEvent%task()
1
Warning: POINTER valued function appears on right-hand side of assignment at
(1)
As far as I can tell, the code runs correctly despite this warning.
the warning is spurious as the "task" function returns a logical, not a
pointer.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/55855] [OOP] incorrect warning with type-bound procedure on pointer-valued base object
2013-01-03 7:29 [Bug fortran/55855] New: incorrect warning with type-bound procedure pointer abensonca at gmail dot com
@ 2013-01-03 9:15 ` janus at gcc dot gnu.org
2013-01-03 9:30 ` [Bug fortran/55855] [OOP] incorrect warning with procedure pointer component " janus at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2013-01-03 9:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55855
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Keywords| |diagnostic
Last reconfirmed| |2013-01-03
CC| |janus at gcc dot gnu.org
Ever Confirmed|0 |1
Summary|incorrect warning with |[OOP] incorrect warning
|type-bound procedure |with type-bound procedure
|pointer |on pointer-valued base
| |object
--- Comment #1 from janus at gcc dot gnu.org 2013-01-03 09:15:00 UTC ---
The following draft patch seems to be sufficient to fix it:
Index: gcc/fortran/expr.c
===================================================================
--- gcc/fortran/expr.c (revision 194763)
+++ gcc/fortran/expr.c (working copy)
@@ -3151,9 +3151,8 @@ gfc_check_assign (gfc_expr *lvalue, gfc_expr *rval
/* This is possibly a typo: x = f() instead of x => f(). */
if (gfc_option.warn_surprising
- && rvalue->expr_type == EXPR_FUNCTION
- && rvalue->symtree->n.sym->attr.pointer)
- gfc_warning ("POINTER valued function appears on right-hand side of "
+ && rvalue->expr_type == EXPR_FUNCTION && gfc_expr_attr (rvalue).pointer)
+ gfc_warning ("POINTER-valued function appears on right-hand side of "
"assignment at %L", &rvalue->where);
/* Check size of array assignments. */
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/55855] [OOP] incorrect warning with procedure pointer component on pointer-valued base object
2013-01-03 7:29 [Bug fortran/55855] New: incorrect warning with type-bound procedure pointer abensonca at gmail dot com
2013-01-03 9:15 ` [Bug fortran/55855] [OOP] incorrect warning with type-bound procedure on pointer-valued base object janus at gcc dot gnu.org
@ 2013-01-03 9:30 ` janus at gcc dot gnu.org
2013-01-03 11:09 ` burnus at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2013-01-03 9:30 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55855
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[OOP] incorrect warning |[OOP] incorrect warning
|with type-bound procedure |with procedure pointer
|on pointer-valued base |component on pointer-valued
|object |base object
--- Comment #2 from janus at gcc dot gnu.org 2013-01-03 09:30:11 UTC ---
Adjusting title. On first glance I falsely identified 'task' as a type-bound
procedure (although it is a procedure pointer component).
Further reduced test case:
implicit none
type :: event
procedure(logical), pointer, nopass :: task
end type event
logical :: r
type(event), pointer :: myEvent
allocate(myEvent)
r=myEvent%task()
end
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/55855] [OOP] incorrect warning with procedure pointer component on pointer-valued base object
2013-01-03 7:29 [Bug fortran/55855] New: incorrect warning with type-bound procedure pointer abensonca at gmail dot com
2013-01-03 9:15 ` [Bug fortran/55855] [OOP] incorrect warning with type-bound procedure on pointer-valued base object janus at gcc dot gnu.org
2013-01-03 9:30 ` [Bug fortran/55855] [OOP] incorrect warning with procedure pointer component " janus at gcc dot gnu.org
@ 2013-01-03 11:09 ` burnus at gcc dot gnu.org
2013-01-03 15:34 ` janus at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu.org @ 2013-01-03 11:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55855
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2013-01-03 11:09:02 UTC ---
(In reply to comment #1)
> The following draft patch seems to be sufficient to fix it:
> + && rvalue->expr_type == EXPR_FUNCTION
> + && gfc_expr_attr (rvalue).pointer)
The patch is OK (obvious) with a test case.
(In reply to comment #2)
> Adjusting title. On first glance I falsely identified 'task' as a type-bound
> procedure (although it is a procedure pointer component).
In any case, the patch (I just had tested an identical patch) fixes the issue
and also works with pointer-returning functions and TBP.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/55855] [OOP] incorrect warning with procedure pointer component on pointer-valued base object
2013-01-03 7:29 [Bug fortran/55855] New: incorrect warning with type-bound procedure pointer abensonca at gmail dot com
` (2 preceding siblings ...)
2013-01-03 11:09 ` burnus at gcc dot gnu.org
@ 2013-01-03 15:34 ` janus at gcc dot gnu.org
2013-01-03 16:11 ` mikael at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2013-01-03 15:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55855
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
AssignedTo|unassigned at gcc dot |janus at gcc dot gnu.org
|gnu.org |
--- Comment #4 from janus at gcc dot gnu.org 2013-01-03 15:33:38 UTC ---
(In reply to comment #3)
> (In reply to comment #1)
> > The following draft patch seems to be sufficient to fix it:
> > + && rvalue->expr_type == EXPR_FUNCTION
> > + && gfc_expr_attr (rvalue).pointer)
>
> The patch is OK (obvious) with a test case.
Thanks. I just checked that it is free of regressions, apart from a failure in
assignment_1.f90, due to the changed error message (which I modified for
orthographical reasons):
Index: gcc/testsuite/gfortran.dg/assignment_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/assignment_1.f90 (revision 194763)
+++ gcc/testsuite/gfortran.dg/assignment_1.f90 (working copy)
@@ -12,7 +12,7 @@ integer, target :: t, s
t = 1
p => s
! We didn't dereference the pointer in the following line.
-p = f() ! { dg-warning "POINTER valued function" "" }
+p = f() ! { dg-warning "POINTER-valued function" "" }
p = p+1
if (p.ne.2) call abort()
if (p.ne.s) call abort()
Will commit soon.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/55855] [OOP] incorrect warning with procedure pointer component on pointer-valued base object
2013-01-03 7:29 [Bug fortran/55855] New: incorrect warning with type-bound procedure pointer abensonca at gmail dot com
` (3 preceding siblings ...)
2013-01-03 15:34 ` janus at gcc dot gnu.org
@ 2013-01-03 16:11 ` mikael at gcc dot gnu.org
2013-01-03 16:15 ` janus at gcc dot gnu.org
2013-01-03 20:18 ` janus at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: mikael at gcc dot gnu.org @ 2013-01-03 16:11 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55855
Mikael Morin <mikael at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mikael at gcc dot gnu.org
--- Comment #5 from Mikael Morin <mikael at gcc dot gnu.org> 2013-01-03 16:10:57 UTC ---
(In reply to comment #3)
> In any case, the patch (I just had tested an identical patch) fixes the issue
> and also works with pointer-returning functions and TBP.
If you have more complete testcases, they are pre-approved to go together with
Janus' patch.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/55855] [OOP] incorrect warning with procedure pointer component on pointer-valued base object
2013-01-03 7:29 [Bug fortran/55855] New: incorrect warning with type-bound procedure pointer abensonca at gmail dot com
` (4 preceding siblings ...)
2013-01-03 16:11 ` mikael at gcc dot gnu.org
@ 2013-01-03 16:15 ` janus at gcc dot gnu.org
2013-01-03 20:18 ` janus at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2013-01-03 16:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55855
--- Comment #6 from janus at gcc dot gnu.org 2013-01-03 16:15:07 UTC ---
Author: janus
Date: Thu Jan 3 16:14:54 2013
New Revision: 194857
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=194857
Log:
2013-01-03 Janus Weil <janus@gcc.gnu.org>
PR fortran/55855
* expr.c (gfc_check_assign): Use 'gfc_expr_attr' to evaluate attributes
of rvalue. Correct hyphenation in error message.
2013-01-03 Janus Weil <janus@gcc.gnu.org>
PR fortran/55855
* gfortran.dg/assignment_1.f90: Modified.
* gfortran.dg/assignment_4.f90: New.
Added:
trunk/gcc/testsuite/gfortran.dg/assignment_4.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/expr.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gfortran.dg/assignment_1.f90
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/55855] [OOP] incorrect warning with procedure pointer component on pointer-valued base object
2013-01-03 7:29 [Bug fortran/55855] New: incorrect warning with type-bound procedure pointer abensonca at gmail dot com
` (5 preceding siblings ...)
2013-01-03 16:15 ` janus at gcc dot gnu.org
@ 2013-01-03 20:18 ` janus at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: janus at gcc dot gnu.org @ 2013-01-03 20:18 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55855
janus at gcc dot gnu.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
--- Comment #7 from janus at gcc dot gnu.org 2013-01-03 20:17:59 UTC ---
(In reply to comment #5)
> (In reply to comment #3)
> > In any case, the patch (I just had tested an identical patch) fixes the issue
> > and also works with pointer-returning functions and TBP.
>
> If you have more complete testcases, they are pre-approved to go together with
> Janus' patch.
I guess the one test case we have should be enough (the patch should fix all
variants).
r194857 fixes the bug on 4.8 trunk. Closing.
Thanks to Andrew for the report!
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-01-03 20:18 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-03 7:29 [Bug fortran/55855] New: incorrect warning with type-bound procedure pointer abensonca at gmail dot com
2013-01-03 9:15 ` [Bug fortran/55855] [OOP] incorrect warning with type-bound procedure on pointer-valued base object janus at gcc dot gnu.org
2013-01-03 9:30 ` [Bug fortran/55855] [OOP] incorrect warning with procedure pointer component " janus at gcc dot gnu.org
2013-01-03 11:09 ` burnus at gcc dot gnu.org
2013-01-03 15:34 ` janus at gcc dot gnu.org
2013-01-03 16:11 ` mikael at gcc dot gnu.org
2013-01-03 16:15 ` janus at gcc dot gnu.org
2013-01-03 20:18 ` janus 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).