@@ -3975,6 +3975,130 @@ else
3975
3975
fi
3976
3976
fi
3977
3977
3978
+ # We use C constructs that became invalid in C23. Check if the compiler
3979
+ # reports a standard higher than C17, with the flags selected above (so the
3980
+ # user can control the language level explicitly to avoid the gcc/clang-only
3981
+ # fallback logic below if preferred).
3982
+ { $as_echo "$as_me:$LINENO: checking whether $CC reports a C standard higher than ISO C17" >&5
3983
+ $as_echo_n "checking whether $CC reports a C standard higher than ISO C17... " >&6; }
3984
+ cat >conftest.$ac_ext <<_ACEOF
3985
+ /* confdefs.h. */
3986
+ _ACEOF
3987
+ cat confdefs.h >>conftest.$ac_ext
3988
+ cat >>conftest.$ac_ext <<_ACEOF
3989
+ /* end confdefs.h. */
3990
+
3991
+ int
3992
+ main ()
3993
+ {
3994
+ #if __STDC_VERSION__ > 201710L
3995
+ choke me
3996
+ #endif
3997
+ ;
3998
+ return 0;
3999
+ }
4000
+ _ACEOF
4001
+ rm -f conftest.$ac_objext
4002
+ if { (ac_try="$ac_compile"
4003
+ case "(($ac_try" in
4004
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
4005
+ *) ac_try_echo=$ac_try;;
4006
+ esac
4007
+ eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
4008
+ $as_echo "$ac_try_echo") >&5
4009
+ (eval "$ac_compile") 2>conftest.er1
4010
+ ac_status=$?
4011
+ grep -v '^ *+' conftest.er1 >conftest.err
4012
+ rm -f conftest.er1
4013
+ cat conftest.err >&5
4014
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
4015
+ (exit $ac_status); } && {
4016
+ test -z "$ac_c_werror_flag" ||
4017
+ test ! -s conftest.err
4018
+ } && test -s conftest.$ac_objext; then
4019
+ POSTC17=no
4020
+ else
4021
+ $as_echo "$as_me: failed program was:" >&5
4022
+ sed 's/^/| /' conftest.$ac_ext >&5
4023
+
4024
+ POSTC17=yes
4025
+ fi
4026
+
4027
+ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4028
+ { $as_echo "$as_me:$LINENO: result: ${POSTC17}" >&5
4029
+ $as_echo "${POSTC17}" >&6; }
4030
+
4031
+ # If a too recent standard was detected with the user's CFLAGS, try asking for
4032
+ # C17 with GNU extensions explicitly.
4033
+ if test "$POSTC17" = yes; then
4034
+ old_CFLAGS="$CFLAGS"
4035
+ { $as_echo "$as_me:$LINENO: checking whether $CC supports -std=gnu17" >&5
4036
+ $as_echo_n "checking whether $CC supports -std=gnu17... " >&6; }
4037
+ if test "${pgac_cv_prog_cc_cflags__std_gnu17+set}" = set; then
4038
+ $as_echo_n "(cached) " >&6
4039
+ else
4040
+ pgac_save_CFLAGS=$CFLAGS
4041
+ CFLAGS="$pgac_save_CFLAGS -std=gnu17"
4042
+ ac_save_c_werror_flag=$ac_c_werror_flag
4043
+ ac_c_werror_flag=yes
4044
+ cat >conftest.$ac_ext <<_ACEOF
4045
+ /* confdefs.h. */
4046
+ _ACEOF
4047
+ cat confdefs.h >>conftest.$ac_ext
4048
+ cat >>conftest.$ac_ext <<_ACEOF
4049
+ /* end confdefs.h. */
4050
+
4051
+ int
4052
+ main ()
4053
+ {
4054
+
4055
+ ;
4056
+ return 0;
4057
+ }
4058
+ _ACEOF
4059
+ rm -f conftest.$ac_objext
4060
+ if { (ac_try="$ac_compile"
4061
+ case "(($ac_try" in
4062
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
4063
+ *) ac_try_echo=$ac_try;;
4064
+ esac
4065
+ eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
4066
+ $as_echo "$ac_try_echo") >&5
4067
+ (eval "$ac_compile") 2>conftest.er1
4068
+ ac_status=$?
4069
+ grep -v '^ *+' conftest.er1 >conftest.err
4070
+ rm -f conftest.er1
4071
+ cat conftest.err >&5
4072
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
4073
+ (exit $ac_status); } && {
4074
+ test -z "$ac_c_werror_flag" ||
4075
+ test ! -s conftest.err
4076
+ } && test -s conftest.$ac_objext; then
4077
+ pgac_cv_prog_cc_cflags__std_gnu17=yes
4078
+ else
4079
+ $as_echo "$as_me: failed program was:" >&5
4080
+ sed 's/^/| /' conftest.$ac_ext >&5
4081
+
4082
+ pgac_cv_prog_cc_cflags__std_gnu17=no
4083
+ fi
4084
+
4085
+ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4086
+ ac_c_werror_flag=$ac_save_c_werror_flag
4087
+ CFLAGS="$pgac_save_CFLAGS"
4088
+ fi
4089
+ { $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__std_gnu17" >&5
4090
+ $as_echo "$pgac_cv_prog_cc_cflags__std_gnu17" >&6; }
4091
+ if test x"$pgac_cv_prog_cc_cflags__std_gnu17" = x"yes"; then
4092
+ CFLAGS="$CFLAGS -std=gnu17"
4093
+ fi
4094
+
4095
+ if test "$CFLAGS" = "$old_CFLAGS"; then
4096
+ { { $as_echo "$as_me:$LINENO: error: cannot proceed" >&5
4097
+ $as_echo "$as_me: error: cannot proceed" >&2;}
4098
+ { (exit 1); exit 1; }; }
4099
+ fi
4100
+ fi
4101
+
3978
4102
# Some versions of GCC support some additional useful warning flags.
3979
4103
# Check whether they are supported, and add them to CFLAGS if so.
3980
4104
# ICC pretends to be GCC but it's lying; it doesn't support these flags,
0 commit comments