@@ -563,7 +563,7 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
563563 TOOLCHAIN_CFLAGS="-errshort=tags"
564564
565565 TOOLCHAIN_CFLAGS_JDK="-mt $TOOLCHAIN_FLAGS"
566- TOOLCHAIN_CFLAGS_JDK_CONLY="-xCC -Xa - W0,-noglobal $TOOLCHAIN_CFLAGS" # C only
566+ TOOLCHAIN_CFLAGS_JDK_CONLY="-W0,-noglobal $TOOLCHAIN_CFLAGS" # C only
567567 TOOLCHAIN_CFLAGS_JDK_CXXONLY="-features=no%except -norunpath -xnolib" # CXX only
568568 TOOLCHAIN_CFLAGS_JVM="-template=no%extdef -features=no%split_init \
569569 -library=stlport4 -mt -features=no%except $TOOLCHAIN_FLAGS"
@@ -584,6 +584,30 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER],
584584 TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:wchar_t-"
585585 fi
586586
587+ # CFLAGS C language level for JDK sources (hotspot only uses C++)
588+ # Ideally we would have a common level across all toolchains so that all sources
589+ # are sure to conform to the same standard. Unfortunately neither our sources nor
590+ # our toolchains are in a condition to support that. But what we loosely aim for is
591+ # C99 level.
592+ if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$TOOLCHAIN_TYPE" = xclang || test "x$TOOLCHAIN_TYPE" = xxlc; then
593+ # This raises the language level for older 4.8 gcc, while lowering it for later
594+ # versions. clang and xlclang support the same flag.
595+ LANGSTD_CFLAGS="-std=c99"
596+ elif test "x$TOOLCHAIN_TYPE" = xsolstudio; then
597+ # We can't turn on -std=c99 without breaking compilation of the splashscreen/png
598+ # utilities. But we can enable c99 as below (previously achieved by using -Xa).
599+ # It is the no_lib that makes the difference.
600+ LANGSTD_CFLAGS="-xc99=all,no_lib"
601+ elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
602+ # MSVC doesn't support C99/C11 explicitly, unless you compile as C++:
603+ # LANGSTD_CFLAGS="/TP"
604+ # but that requires numerous changes to the sources files. So we are limited
605+ # to C89/C90 plus whatever extensions Visual Studio has decided to implement.
606+ # This is the lowest bar for shared code.
607+ LANGSTD_CFLAGS=""
608+ fi
609+ TOOLCHAIN_CFLAGS_JDK_CONLY="$LANGSTD_CFLAGS $TOOLCHAIN_CFLAGS_JDK_CONLY"
610+
587611 # CFLAGS WARNINGS STUFF
588612 # Set JVM_CFLAGS warning handling
589613 if test "x$TOOLCHAIN_TYPE" = xgcc; then
0 commit comments