Browse Source

Disable unused local typedefs warning

This triggers on gcc 4.8.4 for compile time asserts inside of functions

Fixes https://github.com/libsdl-org/SDL/issues/7732

Co-authored-by: Ozkan Sezer <[email protected]>
Sam Lantinga 2 years ago
parent
commit
63b8af3558
3 changed files with 63 additions and 0 deletions
  1. 5 0
      CMakeLists.txt
  2. 36 0
      configure
  3. 22 0
      configure.ac

+ 5 - 0
CMakeLists.txt

@@ -641,6 +641,11 @@ if(USE_GCC OR USE_CLANG OR USE_INTELCC)
     list(APPEND EXTRA_CFLAGS "-Wshadow")
     list(APPEND EXTRA_CFLAGS "-Wshadow")
   endif()
   endif()
 
 
+  check_c_compiler_flag(-Wunused-local-typedefs HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS)
+  if(HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS)
+    list(APPEND EXTRA_CFLAGS "-Wno-unused-local-typedefs")
+  endif()
+
   if(APPLE)
   if(APPLE)
     cmake_push_check_state(RESET)
     cmake_push_check_state(RESET)
     # FIXME: don't use deprecated declarations
     # FIXME: don't use deprecated declarations

+ 36 - 0
configure

@@ -23225,6 +23225,41 @@ printf "%s\n" "$need_gcc_Wno_multichar" >&6; }
     fi
     fi
 }
 }
 
 
+CheckUnusedLocalTypedefs()
+{
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -Wunused-local-typedefs option" >&5
+printf %s "checking for GCC -Wunused-local-typedefs option... " >&6; }
+    have_gcc_unused_local_typedefs=no
+
+    save_CFLAGS="$CFLAGS"
+    CFLAGS="$save_CFLAGS -Wunused-local-typedefs"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+    int x = 0;
+
+int
+main (void)
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+  have_gcc_unused_local_typedefs=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_unused_local_typedefs" >&5
+printf "%s\n" "$have_gcc_unused_local_typedefs" >&6; }
+    CFLAGS="$save_CFLAGS"
+
+    if test x$have_gcc_unused_local_typedefs = xyes; then
+        EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-unused-local-typedefs"
+    fi
+}
+
 CheckWayland()
 CheckWayland()
 {
 {
     # Check whether --enable-video-wayland was given.
     # Check whether --enable-video-wayland was given.
@@ -28571,6 +28606,7 @@ printf "%s\n" "#define SDL_JOYSTICK_VIRTUAL 1" >>confdefs.h
 }
 }
 
 
 CheckWarnAll
 CheckWarnAll
+CheckUnusedLocalTypedefs
 CheckNoStrictAliasing
 CheckNoStrictAliasing
 
 
 CheckEventSignals
 CheckEventSignals

+ 22 - 0
configure.ac

@@ -1674,6 +1674,27 @@ dnl Haiku headers use multicharacter constants all over the place. Ignore these
     fi
     fi
 }
 }
 
 
+dnl See if GCC's -Wunused-local-typedefs is supported and disable it
+dnl  because it triggers on gcc 4.8.4 for compile time asserts inside
+dnl  of functions.
+CheckUnusedLocalTypedefs()
+{
+    AC_MSG_CHECKING(for GCC -Wunused-local-typedefs option)
+    have_gcc_unused_local_typedefs=no
+
+    save_CFLAGS="$CFLAGS"
+    CFLAGS="$save_CFLAGS -Wunused-local-typedefs"
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+    int x = 0;
+    ]],[])], [have_gcc_unused_local_typedefs=yes],[])
+    AC_MSG_RESULT($have_gcc_unused_local_typedefs)
+    CFLAGS="$save_CFLAGS"
+
+    if test x$have_gcc_unused_local_typedefs = xyes; then
+        EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-unused-local-typedefs"
+    fi
+}
+
 dnl Check for Wayland
 dnl Check for Wayland
 CheckWayland()
 CheckWayland()
 {
 {
@@ -3746,6 +3767,7 @@ CheckVirtualJoystick()
 
 
 dnl Do this on all platforms, before everything else (other things might want to override it).
 dnl Do this on all platforms, before everything else (other things might want to override it).
 CheckWarnAll
 CheckWarnAll
+CheckUnusedLocalTypedefs
 CheckNoStrictAliasing
 CheckNoStrictAliasing
 
 
 dnl Do this for every platform, but for some it doesn't mean anything, but better to catch it here anyhow.
 dnl Do this for every platform, but for some it doesn't mean anything, but better to catch it here anyhow.