Are shading language versions forward compatible?

My OpenGL implementation supports shading language version 120, so I put this in my shading code:

#version 120

Will this run on newer versions of OpenGL?

I mean, do shading language versions get deprecated, or will older versions always by supported by newer versions of OpenGL?

Each version of OpenGL explicitly states which versions of GLSL are required to be supported.

No [i]core[/i] profile of OpenGL requires support for GLSL 1.20 or below. Indeed, even OpenGL 3.2 compatibility does not require support for GLSL 1.20.

Note the use of the word “required” above. The specification allows implementations to support earlier GLSL versions, but each version of OpenGL has certain versions which are required to be supported. 3.2 requires support for GLSL 1.40 and 1.50, but does not forbid implementations from supporting earlier ones.

Until OpenGL 4.3, there was no way to query which versions of GLSL were supported by OpenGL. In 4.3+, you can use glGetStringi to query all of the versions that are supported.

Support for versions typically is based on the removal of features from the specification. So GLSL 1.20 can’t be supported by core OpenGL 3.2, because 3.2 core lacks many features that GLSL 1.20 uses.

FYI: the core OpenGL 4.5 specification requires support for GLSL versions all the way back through GLSL 1.40. While the compatibility 4.5 specification requires support for GLSL versions all the way back through GLSL 1.10.