This was happening because objc_eh_runtime_type wanted to create global decls while we were in the middle of processing a function, and cp_finish_decl assumed that if we're in a function the decl must belong to the function. We can avoid that assumption by checking the DECL_CONTEXT rather than current scope. Tested x86_64-pc-linux-gnu, applying to trunk.