From 553028c9ec0c5e98bd163b33b2d53f09084b01ca Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 22 Jun 2014 11:02:56 -0700 Subject: [PATCH] Partial fix for bug 2556 - add compilation flag -Wshadow I added -Wshadow and then turned it off again because of massive variable shadowing in the blit macros. Feel free to go through that code and fix these if you want. Just uncomment CheckWarnShadow in configure.in if you want to try this. --- CMakeLists.txt | 1 + configure | 38 ++++++++++++++++++++++++++++++++++++++ configure.in | 23 +++++++++++++++++++++++ src/events/SDL_events.c | 1 - src/events/SDL_gesture.c | 3 ++- 5 files changed, 64 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e993a7f18c08..e690ba523254b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -334,6 +334,7 @@ if(USE_GCC OR USE_CLANG) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar") endif() endif() + #check_c_compiler_flag(-Wshadow HAVE_GCC_WSHADOW) endif() if(ASSEMBLY) diff --git a/configure b/configure index f6a2960dd6c17..799d1755e3ff4 100755 --- a/configure +++ b/configure @@ -18684,6 +18684,43 @@ $as_echo "$need_gcc_Wno_multichar" >&6; } fi } +CheckWarnShadow() +{ + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -Wshadow option" >&5 +$as_echo_n "checking for GCC -Wshadow option... " >&6; } + have_gcc_Wshadow=no + + save_CFLAGS="$CFLAGS" + CFLAGS="$save_CFLAGS -Wshadow" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + int x = 0; + +int +main () +{ + + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + have_gcc_Wshadow=yes + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $have_gcc_Wshadow" >&5 +$as_echo "$have_gcc_Wshadow" >&6; } + CFLAGS="$save_CFLAGS" + + if test x$have_gcc_Wshadow = xyes; then + EXTRA_CFLAGS="$EXTRA_CFLAGS -Wshadow" + fi +} + CheckWayland() { # Check whether --enable-video-wayland was given. @@ -23337,6 +23374,7 @@ $as_echo "#define SDL_FILESYSTEM_NACL 1" >>confdefs.h esac CheckWarnAll +#CheckWarnShadow # Verify that we have all the platform specific files we need diff --git a/configure.in b/configure.in index 0fc628b24a449..2ea3818305bbb 100644 --- a/configure.in +++ b/configure.in @@ -1159,6 +1159,28 @@ CheckWarnAll() fi } +dnl See if GCC's -Wshadow is supported. +CheckWarnShadow() +{ + AC_MSG_CHECKING(for GCC -Wshadow option) + have_gcc_Wshadow=no + + save_CFLAGS="$CFLAGS" + CFLAGS="$save_CFLAGS -Wshadow" + AC_TRY_COMPILE([ + int x = 0; + ],[ + ],[ + have_gcc_Wshadow=yes + ]) + AC_MSG_RESULT($have_gcc_Wshadow) + CFLAGS="$save_CFLAGS" + + if test x$have_gcc_Wshadow = xyes; then + EXTRA_CFLAGS="$EXTRA_CFLAGS -Wshadow" + fi +} + dnl Check for Wayland CheckWayland() { @@ -3216,6 +3238,7 @@ esac dnl Do this on all platforms, after everything else. CheckWarnAll +#CheckWarnShadow # Verify that we have all the platform specific files we need diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index 7cb4f0cb5cae2..963b9bd7cf2d5 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -302,7 +302,6 @@ SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action, For now we'll guarantee it's valid at least until the next call to SDL_PeepEvents() */ - SDL_SysWMEntry *wmmsg; if (SDL_EventQ.wmmsg_free) { wmmsg = SDL_EventQ.wmmsg_free; SDL_EventQ.wmmsg_free = wmmsg->next; diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c index f7a9b4d388c47..46a554635d32a 100644 --- a/src/events/SDL_gesture.c +++ b/src/events/SDL_gesture.c @@ -473,7 +473,6 @@ static int SDL_SendDollarRecord(SDL_GestureTouch* touch,SDL_GestureID gestureId) void SDL_GestureProcessEvent(SDL_Event* event) { float x,y; - SDL_FloatPoint path[DOLLARNPOINTS]; int index; int i; float pathDx, pathDy; @@ -497,6 +496,8 @@ void SDL_GestureProcessEvent(SDL_Event* event) /* Finger Up */ if (event->type == SDL_FINGERUP) { + SDL_FloatPoint path[DOLLARNPOINTS]; + inTouch->numDownFingers--; #ifdef ENABLE_DOLLAR