@@ -3949,6 +3949,130 @@ else
3949
3949
fi
3950
3950
fi
3951
3951
3952
+ # We use C constructs that became invalid in C23. Check if the compiler
3953
+ # reports a standard higher than C17, with the flags selected above (so the
3954
+ # user can control the language level explicitly to avoid the gcc/clang-only
3955
+ # fallback logic below if preferred).
3956
+ { $as_echo "$as_me:$LINENO: checking whether $CC reports a C standard higher than ISO C17" >&5
3957
+ $as_echo_n "checking whether $CC reports a C standard higher than ISO C17... " >&6; }
3958
+ cat >conftest.$ac_ext <<_ACEOF
3959
+ /* confdefs.h. */
3960
+ _ACEOF
3961
+ cat confdefs.h >>conftest.$ac_ext
3962
+ cat >>conftest.$ac_ext <<_ACEOF
3963
+ /* end confdefs.h. */
3964
+
3965
+ int
3966
+ main ()
3967
+ {
3968
+ #if __STDC_VERSION__ > 201710L
3969
+ choke me
3970
+ #endif
3971
+ ;
3972
+ return 0;
3973
+ }
3974
+ _ACEOF
3975
+ rm -f conftest.$ac_objext
3976
+ if { (ac_try="$ac_compile"
3977
+ case "(($ac_try" in
3978
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
3979
+ *) ac_try_echo=$ac_try;;
3980
+ esac
3981
+ eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
3982
+ $as_echo "$ac_try_echo") >&5
3983
+ (eval "$ac_compile") 2>conftest.er1
3984
+ ac_status=$?
3985
+ grep -v '^ *+' conftest.er1 >conftest.err
3986
+ rm -f conftest.er1
3987
+ cat conftest.err >&5
3988
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
3989
+ (exit $ac_status); } && {
3990
+ test -z "$ac_c_werror_flag" ||
3991
+ test ! -s conftest.err
3992
+ } && test -s conftest.$ac_objext; then
3993
+ POSTC17=no
3994
+ else
3995
+ $as_echo "$as_me: failed program was:" >&5
3996
+ sed 's/^/| /' conftest.$ac_ext >&5
3997
+
3998
+ POSTC17=yes
3999
+ fi
4000
+
4001
+ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4002
+ { $as_echo "$as_me:$LINENO: result: ${POSTC17}" >&5
4003
+ $as_echo "${POSTC17}" >&6; }
4004
+
4005
+ # If a too recent standard was detected with the user's CFLAGS, try asking for
4006
+ # C17 with GNU extensions explicitly.
4007
+ if test "$POSTC17" = yes; then
4008
+ old_CFLAGS="$CFLAGS"
4009
+ { $as_echo "$as_me:$LINENO: checking whether $CC supports -std=gnu17" >&5
4010
+ $as_echo_n "checking whether $CC supports -std=gnu17... " >&6; }
4011
+ if test "${pgac_cv_prog_cc_cflags__std_gnu17+set}" = set; then
4012
+ $as_echo_n "(cached) " >&6
4013
+ else
4014
+ pgac_save_CFLAGS=$CFLAGS
4015
+ CFLAGS="$pgac_save_CFLAGS -std=gnu17"
4016
+ ac_save_c_werror_flag=$ac_c_werror_flag
4017
+ ac_c_werror_flag=yes
4018
+ cat >conftest.$ac_ext <<_ACEOF
4019
+ /* confdefs.h. */
4020
+ _ACEOF
4021
+ cat confdefs.h >>conftest.$ac_ext
4022
+ cat >>conftest.$ac_ext <<_ACEOF
4023
+ /* end confdefs.h. */
4024
+
4025
+ int
4026
+ main ()
4027
+ {
4028
+
4029
+ ;
4030
+ return 0;
4031
+ }
4032
+ _ACEOF
4033
+ rm -f conftest.$ac_objext
4034
+ if { (ac_try="$ac_compile"
4035
+ case "(($ac_try" in
4036
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
4037
+ *) ac_try_echo=$ac_try;;
4038
+ esac
4039
+ eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
4040
+ $as_echo "$ac_try_echo") >&5
4041
+ (eval "$ac_compile") 2>conftest.er1
4042
+ ac_status=$?
4043
+ grep -v '^ *+' conftest.er1 >conftest.err
4044
+ rm -f conftest.er1
4045
+ cat conftest.err >&5
4046
+ $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
4047
+ (exit $ac_status); } && {
4048
+ test -z "$ac_c_werror_flag" ||
4049
+ test ! -s conftest.err
4050
+ } && test -s conftest.$ac_objext; then
4051
+ pgac_cv_prog_cc_cflags__std_gnu17=yes
4052
+ else
4053
+ $as_echo "$as_me: failed program was:" >&5
4054
+ sed 's/^/| /' conftest.$ac_ext >&5
4055
+
4056
+ pgac_cv_prog_cc_cflags__std_gnu17=no
4057
+ fi
4058
+
4059
+ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
4060
+ ac_c_werror_flag=$ac_save_c_werror_flag
4061
+ CFLAGS="$pgac_save_CFLAGS"
4062
+ fi
4063
+ { $as_echo "$as_me:$LINENO: result: $pgac_cv_prog_cc_cflags__std_gnu17" >&5
4064
+ $as_echo "$pgac_cv_prog_cc_cflags__std_gnu17" >&6; }
4065
+ if test x"$pgac_cv_prog_cc_cflags__std_gnu17" = x"yes"; then
4066
+ CFLAGS="$CFLAGS -std=gnu17"
4067
+ fi
4068
+
4069
+ if test "$CFLAGS" = "$old_CFLAGS"; then
4070
+ { { $as_echo "$as_me:$LINENO: error: cannot proceed" >&5
4071
+ $as_echo "$as_me: error: cannot proceed" >&2;}
4072
+ { (exit 1); exit 1; }; }
4073
+ fi
4074
+ fi
4075
+
3952
4076
# set CFLAGS_VECTOR from the environment, if available
3953
4077
if test "$ac_env_CFLAGS_VECTOR_set" = set; then
3954
4078
CFLAGS_VECTOR=$ac_env_CFLAGS_VECTOR_value
0 commit comments