The source
stop1
end
is not a valid Fortran 90/95/2003/2008/2018 program.
It is, however, a program that is accepted by GCC 4.8.5, seemingly with the intended result.
It is accepted by this version of the compiler because it does not have the diagnostic capability to reject the program. Later versions of GCC do include such capability.
No compiler is required to have this capability: the error in this source is one the programmer must take responsibility for. By using a newer compiler you are taking advantage of the improvements in its optional error checking focus. One should be grateful to a compiler which points out mistakes even when it doesn't have to.
If you have broken code like my example here: fix it. Using the flag -std=f95 for later versions of GCC won't help: the flag requests checking for stricter conformance to the Fortran 95 standard (against allowing non-standard extensions or features from Fortran 2003+) but as above, the code is not valid Fortran 95 code.
Note, however, that
stop1
end
is a valid Fortran 90+ program in fixed-form source. If you're trying to compile fixed-form source as free-form source, then as above early versions of GCC will accept it while later versions will reject it. In this case, explicitly tell the compiler to compile as fixed-form source or change the source to be valid so-called intersection format.