http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46152
--- Comment #14 from Steve Kargl <sgk at troutmask dot apl.washington.edu> 2010-10-26 21:01:57 UTC --- On Tue, Oct 26, 2010 at 07:43:49PM +0000, burnus at gcc dot gnu.org wrote: > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46152 > > --- Comment #13 from Tobias Burnus <burnus at gcc dot gnu.org> 2010-10-26 > 19:43:43 UTC --- > (In reply to comment #12) > > New patch attached. This passed regression testing. > > The patch is OK from my side. > > I assume there is still an error printed but error but the extra error causes > that succeeding checks fail thus you removed the following line: > > - allocate(tx :: x(5)) ! { dg-error "is not an accessible derived type" } > > Otherwise, "is not an accessible derived type" is a nicer error message then > "error in CLASS IS specification at" but I assume one cannot have everything - > and the latter is also sufficiently clear. > The error message "is not an accessible derived type" make no sense to me. In the testcase, the statement 'allocate(tx :: x(5))' appears and there is no other appearance of 'tx'. There is no reason (imho) to assume that 'tx' was a derived type over some simple typographically error (ie., a syntax error). In the following fixed-form program, program hmm doubleprecision, allocatable :: x allocate(doubleprecicion :: x) end program hmm saying 'doubleprecicion' is inaccessible derived type seems odd. match_type_spec() now simply looks at 'tx' and asks if is a derived type. If yes, match_type_spec() returns MATCH_YES. If no, then 'tx' is compared against the intrinsic types. 'tx' clearly is not an intrinsic to match_type_spec() returns MATCH_NO. Also note, the name of the function is match_type_spec(), I've removed these chunks of code - old_locus = gfc_current_locus; - if (gfc_match (" :: ") != MATCH_YES) - return MATCH_ERROR; - gfc_current_locus = old_locus; /* Enfore F03:C401. */ if (ts->u.derived->attr.abstract) { @@ -2771,8 +2776,6 @@ match_type_spec (gfc_typespec *ts) } return MATCH_YES; } - else if (m == MATCH_ERROR && gfc_match (" :: ") == MATCH_YES) - return MATCH_ERROR; that look for '::'. The double-colon is not part of a type-spec. Now, match_type_spec() can never return a MATCH_ERROR condition, which may mean the "is not an accessible derived type" message may never triggered. Yes, I think it may be dead code. OTOH, I don't use the OO features of Fortran and I certainly will defer to Janus if he needs this error message for something other than allocate(). What clearly needs to go is the gfc_match_symbol() in match_derived_type_spec(). I'll ping Janus for comment before proceeding.