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
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))
Submitted patch, pending review: http://gcc.gnu.org/ml/fortran/2012-02/msg00085.html
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
FIXED on the trunk (i.e. GCC 4.8).