In OpenCL C++ mode, the "program scope variable must reside ..."
diagnostic is firing early in some cases, potentially confusing the
user. It is the first diagnostic reported for
int g(global int *p) {}
but the actual problem is the undeclared identifier global.
The main reason to improve error reporting for the example above is
that OpenCL C address space qualifiers such as global are not part
of OpenCL C++. This means the PSV diagnostic will fire when porting
OpenCL C code to OpenCL C++ if an address space qualifier is left in
by accident.
The PSV diagnostic is emitted for the example above because the parser
believes g is a variable declaration instead of a function
declaration. This seems to be inherent to C++ parsing, so postpone
the PSV diagnostic until we have parsed the entire declarator group.
We still get the PSV diagnostic for the example, but it is no longer
the first so it should be easier for the user to see what the actual
problem is.