See review comment http://gcc.gnu.org/ml/fortran/2009-09/msg00298.html
For two longer test cases, see http://gcc.gnu.org/ml/fortran/2009-09/msg00295.html Currently, SELECT TYPE(type) uses: + /* Special case: If we're in a SELECT TYPE block, + replace the selector variable by a temporary. */ + if (gfc_current_state () == COMP_SELECT_TYPE + && st && st->n.sym == type_selector) + st = select_type_tmp; + That fails (a) If the current state is not COMP_SELECT_TYPE (b) If one nests SELECT TYPE Example: select type (mt2) type is(t2) mt2%i = 5 select type(mt3) type is(t3) mt3%j = mt2%i class default stop 'error' end select class default stop 'error' end select mt3%j = mt2%i 1 Error: 'i' at (1) is not a member of the 't1' structure -- Summary: [OOP/Polymorphism] Nesting of SELECT TYPE Product: gcc Version: 4.5.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: burnus at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41579