diff --git a/config/c-compiler.m4 b/config/c-compiler.m4 index 88333ef301d..629572ee350 100644 --- a/config/c-compiler.m4 +++ b/config/c-compiler.m4 @@ -184,13 +184,9 @@ fi])# PGAC_C_TYPEOF AC_DEFUN([PGAC_C_TYPEOF_UNQUAL], [AC_CACHE_CHECK(for typeof_unqual, pgac_cv_c_typeof_unqual, [pgac_cv_c_typeof_unqual=no -# Test the underscore variant first so that there is a higher chance -# that clang used for bitcode also supports it, since we don't test -# that separately. -# # Test with a void pointer, because MSVC doesn't handle that, and we # need that for copyObject(). -for pgac_kw in __typeof_unqual__ typeof_unqual; do +for pgac_kw in typeof_unqual __typeof_unqual__; do AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [int x = 0; $pgac_kw(x) y; @@ -248,7 +244,7 @@ AC_DEFUN([PGAC_CXX_TYPEOF_UNQUAL], [AC_CACHE_CHECK(for C++ typeof_unqual, pgac_cv_cxx_typeof_unqual, [pgac_cv_cxx_typeof_unqual=no AC_LANG_PUSH(C++) -for pgac_kw in __typeof_unqual__ typeof_unqual; do +for pgac_kw in typeof_unqual __typeof_unqual__; do AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [int x = 0; $pgac_kw(x) y; diff --git a/configure b/configure index f69331f0748..5aec0afa9ab 100755 --- a/configure +++ b/configure @@ -15084,13 +15084,9 @@ if ${pgac_cv_c_typeof_unqual+:} false; then : $as_echo_n "(cached) " >&6 else pgac_cv_c_typeof_unqual=no -# Test the underscore variant first so that there is a higher chance -# that clang used for bitcode also supports it, since we don't test -# that separately. -# # Test with a void pointer, because MSVC doesn't handle that, and we # need that for copyObject(). -for pgac_kw in __typeof_unqual__ typeof_unqual; do +for pgac_kw in typeof_unqual __typeof_unqual__; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -15141,7 +15137,7 @@ ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu -for pgac_kw in __typeof_unqual__ typeof_unqual; do +for pgac_kw in typeof_unqual __typeof_unqual__; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ diff --git a/meson.build b/meson.build index f7a87edcc94..46bd6b1468a 100644 --- a/meson.build +++ b/meson.build @@ -2969,13 +2969,9 @@ endif # Check if the C compiler understands typeof_unqual or a variant. Define # HAVE_TYPEOF_UNQUAL if so, and define 'typeof_unqual' to the actual key word. # -# Test the underscore variant first so that there is a higher chance -# that clang used for bitcode also supports it, since we don't test -# that separately. -# # Test with a void pointer, because MSVC doesn't handle that, and we # need that for copyObject(). -foreach kw : ['__typeof_unqual__', 'typeof_unqual'] +foreach kw : ['typeof_unqual', '__typeof_unqual__'] if cc.compiles(''' int main(void) { @@ -3002,7 +2998,7 @@ endforeach # Check if the C++ compiler understands typeof_unqual or a variant. if have_cxx - foreach kw : ['__typeof_unqual__', 'typeof_unqual'] + foreach kw : ['typeof_unqual', '__typeof_unqual__'] if cxx.compiles(''' int main(void) { diff --git a/src/include/c.h b/src/include/c.h index 29fef2f54e1..8987a121d6a 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -432,6 +432,21 @@ extern "C++" #define unlikely(x) ((x) != 0) #endif +/* + * When we call clang to generate bitcode, we might be using configure results + * from a different compiler, which might not be fully compatible with the + * clang we are using. The fully correct solution would be to run a separate + * set of configure tests for that clang-for-bitcode, but that could be very + * difficult to implement, and in practice clang supports most things other + * compilers support. So this section just contains some hardcoded ugliness + * to override some configure results where it is necessary. + */ +#if defined(__clang__) +#if __clang_major__ < 19 +#undef HAVE_TYPEOF_UNQUAL +#endif +#endif /* __clang__ */ + /* * Provide typeof in C++ for C++ compilers that don't support typeof natively. * It might be spelled __typeof__ instead of typeof, in which case