When trying to build JDK 10 with gcc 4.4.7 (e.g. RHEL 6) then the build fails with:
In file included from /home/jdk9/jdk10u/src/hotspot/share/runtime/os.inline.hpp:30,
from /home/jdk9/jdk10u/src/hotspot/share/runtime/thread.inline.hpp:29,
from /home/jdk9/jdk10u/src/hotspot/share/runtime/handles.inline.hpp:29,
from /home/jdk9/jdk10u/src/hotspot/share/runtime/reflectionUtils.hpp:32,
from /home/jdk9/jdk10u/src/hotspot/share/classfile/systemDictionary.hpp:34,
from /home/jdk9/jdk10u/src/hotspot/share/ci/ciEnv.hpp:30,
from /home/jdk9/jdk10u/src/hotspot/share/ci/ciUtilities.hpp:28,
from /home/jdk9/jdk10u/src/hotspot/share/ci/ciNullObject.hpp:30,
from /home/jdk9/jdk10u/src/hotspot/share/ci/ciConstant.hpp:29,
from /home/jdk9/jdk10u/src/hotspot/share/ci/ciArray.hpp:29,
from /home/jdk9/jdk10u/src/hotspot/share/precompiled/precompiled.hpp:35:
/home/jdk9/jdk10u/src/hotspot/os/linux/os_linux.inline.hpp: In static member function ���static dirent* os::readdir(DIR*, dirent*)���:
/home/jdk9/jdk10u/src/hotspot/os/linux/os_linux.inline.hpp:103: error: #pragma GCC diagnostic not allowed inside functions
/home/jdk9/jdk10u/src/hotspot/os/linux/os_linux.inline.hpp:104: error: #pragma GCC diagnostic not allowed inside functions
/home/jdk9/jdk10u/src/hotspot/os/linux/os_linux.inline.hpp:120: error: #pragma GCC diagnostic not allowed inside functions
In file included from /home/jdk9/jdk10u/src/hotspot/share/runtime/os.inline.hpp:30,
from /home/jdk9/jdk10u/src/hotspot/share/runtime/thread.inline.hpp:29,
from /home/jdk9/jdk10u/src/hotspot/share/runtime/handles.inline.hpp:29,
from /home/jdk9/jdk10u/src/hotspot/share/runtime/reflectionUtils.hpp:32,
from /home/jdk9/jdk10u/src/hotspot/share/classfile/systemDictionary.hpp:34,
from /home/jdk9/jdk10u/src/hotspot/share/ci/ciEnv.hpp:30,
from /home/jdk9/jdk10u/src/hotspot/share/ci/ciUtilities.hpp:28,
from /home/jdk9/jdk10u/src/hotspot/share/ci/ciNullObject.hpp:30,
from /home/jdk9/jdk10u/src/hotspot/share/ci/ciConstant.hpp:29,
from /home/jdk9/jdk10u/src/hotspot/share/ci/ciArray.hpp:29,
from /home/jdk9/jdk10u/src/hotspot/share/precompiled/precompiled.hpp:35:
/home/jdk9/jdk10u/src/hotspot/os/linux/os_linux.inline.hpp: In static member function ���static dirent* os::readdir(DIR*, dirent*)���:
/home/jdk9/jdk10u/src/hotspot/os/linux/os_linux.inline.hpp:103: error: #pragma GCC diagnostic not allowed inside functions
/home/jdk9/jdk10u/src/hotspot/os/linux/os_linux.inline.hpp:104: error: #pragma GCC diagnostic not allowed inside functions
/home/jdk9/jdk10u/src/hotspot/os/linux/os_linux.inline.hpp:120: error: #pragma GCC diagnostic not allowed inside functions
gmake[3]: *** [/home/jdk9/jdk10u/build/release/hotspot/variant-server/libjvm/gtest/objs/precompiled/precompiled.hpp.gch] Error 1
Moving the pragma outside the function lets the build proceed.