public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/52270] New: [OOP] Polymorphic vars: wrong intent(in) check, passing nonptr variable to intent(in) ptr dummy
@ 2012-02-16 8:15 burnus at gcc dot gnu.org
2012-02-16 9:57 ` [Bug fortran/52270] " burnus at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-02-16 8:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52270
Bug #: 52270
Summary: [OOP] Polymorphic vars: wrong intent(in) check,
passing nonptr variable to intent(in) ptr dummy
Classification: Unclassified
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: burnus@gcc.gnu.org
>From http://j3-fortran.org/doc/meeting/197/12-131.txt
The following program is rejected with:
-----------------------------------------------------
p%c = 3
1
Error: Dummy argument 'p' with INTENT(IN) in variable definition context
(assignment) at (1)
Call s(x)
1
Error: Actual argument to 'p' at (1) must be polymorphic
-----------------------------------------------------
The first item is bogus as 'p' is a pointer and pointer intents only affect the
pointer association status. Something must go wrong with regards to polymorphic
types.
The second error is formally correct, but the quoted interpretation request by
Malcolm Cohen suggests to make it valid; that would be consistent with the
Fortran 2008 changes regarding "pointer,intent(in)". One could consider to
defer this part until it has passed J3 (or even WG3) voting.
Program m013
Type t
Real c
End Type
Type(t),Target :: x
Call s(x)
Print *,x%c
Contains
Subroutine s(p)
Class(t),Pointer,Intent(In) :: p
p%c = 3
End Subroutine
End Program
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/52270] [OOP] Polymorphic vars: wrong intent(in) check, passing nonptr variable to intent(in) ptr dummy
2012-02-16 8:15 [Bug fortran/52270] New: [OOP] Polymorphic vars: wrong intent(in) check, passing nonptr variable to intent(in) ptr dummy burnus at gcc dot gnu.org
@ 2012-02-16 9:57 ` burnus at gcc dot gnu.org
2012-02-21 13:38 ` burnus at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-02-16 9:57 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52270
Tobias Burnus <burnus at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-16 09:54:51 UTC ---
Untested patch for both issues.
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -4650,3 +4650,4 @@ gfc_check_vardef_context (gfc_expr* e, bool pointer, bool
alloc_obj,
check_intentin = true;
- ptr_component = sym->attr.pointer;
+ ptr_component = (sym->ts.type == BT_CLASS)
+ ? CLASS_DATA (sym)->attr.class_pointer : sym->attr.pointer;
for (ref = e->ref; ref && check_intentin; ref = ref->next)
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -1708,5 +1708,6 @@ compare_parameter (gfc_symbol *formal, gfc_expr *actual,
- /* F2008, 12.5.2.5. */
+ /* F2008, 12.5.2.5; IR F08/0073. */
if (formal->ts.type == BT_CLASS
- && (CLASS_DATA (formal)->attr.class_pointer
+ && ((CLASS_DATA (formal)->attr.class_pointer
+ && !formal->attr.intent == INTENT_IN)
|| CLASS_DATA (formal)->attr.allocatable))
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/52270] [OOP] Polymorphic vars: wrong intent(in) check, passing nonptr variable to intent(in) ptr dummy
2012-02-16 8:15 [Bug fortran/52270] New: [OOP] Polymorphic vars: wrong intent(in) check, passing nonptr variable to intent(in) ptr dummy burnus at gcc dot gnu.org
2012-02-16 9:57 ` [Bug fortran/52270] " burnus at gcc dot gnu.org
@ 2012-02-21 13:38 ` burnus at gcc dot gnu.org
2012-03-02 13:08 ` burnus at gcc dot gnu.org
2012-03-02 13:35 ` burnus at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-02-21 13:38 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52270
--- Comment #2 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-02-21 13:36:30 UTC ---
Submitted patch, pending review:
http://gcc.gnu.org/ml/fortran/2012-02/msg00085.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/52270] [OOP] Polymorphic vars: wrong intent(in) check, passing nonptr variable to intent(in) ptr dummy
2012-02-16 8:15 [Bug fortran/52270] New: [OOP] Polymorphic vars: wrong intent(in) check, passing nonptr variable to intent(in) ptr dummy burnus at gcc dot gnu.org
2012-02-16 9:57 ` [Bug fortran/52270] " burnus at gcc dot gnu.org
2012-02-21 13:38 ` burnus at gcc dot gnu.org
@ 2012-03-02 13:08 ` burnus at gcc dot gnu.org
2012-03-02 13:35 ` burnus at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-03-02 13:08 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52270
--- Comment #3 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-03-02 13:07:55 UTC ---
Author: burnus
Date: Fri Mar 2 13:07:46 2012
New Revision: 184784
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=184784
Log:
2012-03-02 Tobias Burnus <burnus@net-b.de>
PR fortran/52270
* expr.c (gfc_check_vardef_context): Fix check for
intent-in polymorphic pointer .
* interface.c (compare_parameter): Allow passing TYPE to
intent-in polymorphic pointer.
2012-03-02 Tobias Burnus <burnus@net-b.de>
PR fortran/52270
* gfortran.dg/class_51.f90: New.
Added:
trunk/gcc/testsuite/gfortran.dg/class_51.f90
trunk/gcc/testsuite/gfortran.dg/class_52.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/expr.c
trunk/gcc/fortran/interface.c
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug fortran/52270] [OOP] Polymorphic vars: wrong intent(in) check, passing nonptr variable to intent(in) ptr dummy
2012-02-16 8:15 [Bug fortran/52270] New: [OOP] Polymorphic vars: wrong intent(in) check, passing nonptr variable to intent(in) ptr dummy burnus at gcc dot gnu.org
` (2 preceding siblings ...)
2012-03-02 13:08 ` burnus at gcc dot gnu.org
@ 2012-03-02 13:35 ` burnus at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: burnus at gcc dot gnu.org @ 2012-03-02 13:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52270
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> 2012-03-02 13:35:13 UTC ---
FIXED on the trunk (i.e. GCC 4.8).
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-03-02 13:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-16 8:15 [Bug fortran/52270] New: [OOP] Polymorphic vars: wrong intent(in) check, passing nonptr variable to intent(in) ptr dummy burnus at gcc dot gnu.org
2012-02-16 9:57 ` [Bug fortran/52270] " burnus at gcc dot gnu.org
2012-02-21 13:38 ` burnus at gcc dot gnu.org
2012-03-02 13:08 ` burnus at gcc dot gnu.org
2012-03-02 13:35 ` 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).