The attached patch was provided by Steve Kargl. After exploring for possible other checks I settled on leaving the patch intact. Two existing test cases updated as different but sensible error messages resulted. Regression tested on main line. OK to commit? Regards, Jerry Author: Steve Kargl Date: Mon Dec 26 14:07:04 2022 -0800 Modify checks to avoid referencing NULL pointer. Update test cases with error messages that changed as a result. gcc/fortran/ChangeLog: * decl.cc (attr_decl1): Guard against NULL pointer. * parse.cc (match_deferred_characteristics): Include BT_CLASS in check for derived being undefined. gcc/testsuite/ChangeLog: * gfortran.dg/class_result_4.f90: Update error message check. * gfortran.dg/pr85779_3.f90: Update error message check.