Found at: http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/73c7b88ffbe8e1d5 The following (see URL above) is valid but gfortran rejects it with: Error: Pointer assignment target has PROTECTED attribute at (1) > C538: > > "A pointer object that has the PROTECTED attribute and is accessed by > use association shall not appear as (1) A pointer-object in a pointer- > assignment-stmt..." > > C538 doesn't forbid using a protected pointer as the target of a > pointer-assignment-stmt. module m implicit none integer, pointer, protected :: protected_pointer end module m program p use m implicit none integer, pointer :: unprotected_pointer unprotected_pointer => protected_pointer end program p
First patch - completely untested/uncompiled: Index: expr.c =================================================================== --- expr.c (Revision 140340) +++ expr.c @@ -3053 +3053,2 @@ gfc_check_pointer_assign (gfc_expr *lval - if (attr.is_protected && attr.use_assoc) + if (attr.is_protected && attr.use_assoc + && !(attr.pointer || attr.proc_pointer)) I don't quite understand why one gets "Error: PROTECTED at (1) only allowed in specification part of a module" for the following example. module m implicit none integer, pointer, protected :: protected_pointer integer, target, protected :: protected_target end module m program p use m implicit none integer, pointer :: unprotected_pointer unprotected_pointer => protected_target ! OK, is rejected unprotected_pointer => protected_pointer ! WRONG, is wrongly REJECTED protected_pointer => unprotected_pointer ! OK, is rejected, BUT MATCH ERROR end program p
Subject: Bug 37504 Author: burnus Date: Thu Sep 25 15:01:16 2008 New Revision: 140663 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=140663 Log: 2008-09-25 Tobias Burnus <burnus@net-b.de> PR fortran/37504 * expr.c (gfc_check_pointer_assign): Allow assignment of protected pointers. * match.c (gfc_match_assignment,gfc_match_pointer_assignment): Remove unreachable code. 2008-09-25 Tobias Burnus <burnus@net-b.de> PR fortran/37504 * gfortran.dg/protected_7.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/protected_7.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/expr.c trunk/gcc/fortran/match.c trunk/gcc/testsuite/ChangeLog
Subject: Bug 37504 Author: burnus Date: Fri Sep 26 15:17:25 2008 New Revision: 140695 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=140695 Log: 2008-09-26 Tobias Burnus <burnus@net-b.de> PR fortran/37504 * expr.c (gfc_check_pointer_assign): Allow assignment of protected pointers. 2008-09-26 Tobias Burnus <burnus@net-b.de> PR fortran/37504 * gfortran.dg/protected_7.f90: New test. Added: branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/protected_7.f90 Modified: branches/gcc-4_3-branch/gcc/fortran/ChangeLog branches/gcc-4_3-branch/gcc/fortran/expr.c branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
FIXED on the trunk (4.4) and on the 4.3 branch.