https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50550
markeggleston at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |markeggleston at gcc dot gnu.org --- Comment #8 from markeggleston at gcc dot gnu.org --- @@ -2858,7 +2858,8 @@ variable_decl (int elem) { if (gfc_match (" =>") == MATCH_YES) { - if (!current_attr.pointer) + gfc_find_symbol (name, gfc_current_ns, 1, &sym); + if (!(current_attr.pointer || (sym && sym->attr.pointer))) { gfc_error ("Initialization at %C isn't for a pointer variable"); m = MATCH_ERROR; The contents of current_attr only applies to the line currently being parsed so will not have the pointer attribute. In the case where the pointer attribute has already been declared a matching symbol should exist that has that attribute set. However, if the pointer attribute is declared after the initialisation it is not known when initialisation line is parsed. The parsing of pointer occurs after the initialisation parsing is complete. For this to be fixed where the attribute is declared after initialisation error detection would have to be deferred until after parsing has been completed. The above change does not result in any unexpected test case failures when running make with check-fortran. I'm no longer working on this PR as I do not know how to proceed.