Fixed bug 1646 - Warnings from clang with -Weverything
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
diff --git a/include/begin_code.h b/include/begin_code.h
index 04e78c6..2a97ab7 100644
--- a/include/begin_code.h
+++ b/include/begin_code.h
@@ -134,6 +134,16 @@
#endif
#endif /* SDL_FORCE_INLINE not defined */
+#ifndef SDL_NORETURN
+#if defined(__GNUC__)
+#define SDL_NORETURN __attribute__((noreturn))
+#elif defined(_MSC_VER)
+#define SDL_NORETURN __declspec(noreturn)
+#else
+#define SDL_NORETURN
+#endif
+#endif /* SDL_NORETURN not defined */
+
/* Apparently this is needed by several Windows compilers */
#if !defined(__MACH__)
#ifndef NULL
diff --git a/src/SDL_assert.c b/src/SDL_assert.c
index a21f70b..5e2603b 100644
--- a/src/SDL_assert.c
+++ b/src/SDL_assert.c
@@ -111,7 +111,8 @@ static void SDL_GenerateAssertionReport(void)
}
}
-static void SDL_ExitProcess(int exitcode)
+
+static SDL_NORETURN void SDL_ExitProcess(int exitcode)
{
#ifdef __WIN32__
ExitProcess(exitcode);
@@ -120,7 +121,8 @@ static void SDL_ExitProcess(int exitcode)
#endif
}
-static void SDL_AbortAssertion(void)
+
+static SDL_NORETURN void SDL_AbortAssertion(void)
{
SDL_Quit();
SDL_ExitProcess(42);
diff --git a/src/test/SDL_test_fuzzer.c b/src/test/SDL_test_fuzzer.c
index 0aeb79f..5071e08 100644
--- a/src/test/SDL_test_fuzzer.c
+++ b/src/test/SDL_test_fuzzer.c
@@ -443,7 +443,7 @@ SDLTest_RandomSint64BoundaryValue(Sint64 boundary1, Sint64 boundary2, SDL_bool v
float
SDLTest_RandomUnitFloat()
{
- return (float) SDLTest_RandomUint32() / UINT_MAX;
+ return SDLTest_RandomUint32() / (float) UINT_MAX;
}
float
diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c
index e70a5d3..0fd0a31 100644
--- a/src/test/SDL_test_harness.c
+++ b/src/test/SDL_test_harness.c
@@ -206,7 +206,7 @@ SDLTest_SetTestTimeout(int timeout, void (*callback)())
/**
* \brief Timeout handler. Aborts test run and exits harness process.
*/
-static void
+static SDL_NORETURN void
SDLTest_BailOut()
{
SDLTest_LogError("TestCaseTimeout timer expired. Aborting test run.");
diff --git a/src/test/SDL_test_log.c b/src/test/SDL_test_log.c
index a22b10f..00298b6 100644
--- a/src/test/SDL_test_log.c
+++ b/src/test/SDL_test_log.c
@@ -26,7 +26,9 @@
*/
/* quiet windows compiler warnings */
-#define _CRT_SECURE_NO_WARNINGS
+#if defined(_MSC_VER)
+# define _CRT_SECURE_NO_WARNINGS
+#endif
#include "SDL_config.h"
diff --git a/src/video/SDL_blit_N.c b/src/video/SDL_blit_N.c
index 534d79b..11398fb 100644
--- a/src/video/SDL_blit_N.c
+++ b/src/video/SDL_blit_N.c
@@ -1113,6 +1113,7 @@ Blit_RGB101010_index8(SDL_BlitInfo * info)
(((*src)&0x0000F800)>>6)| \
(((*src)&0x000000F8)>>3)); \
}
+#ifndef USE_DUFFS_LOOP
#define RGB888_RGB555_TWO(dst, src) { \
*(Uint32 *)(dst) = (((((src[HI])&0x00F80000)>>9)| \
(((src[HI])&0x0000F800)>>6)| \
@@ -1121,6 +1122,7 @@ Blit_RGB101010_index8(SDL_BlitInfo * info)
(((src[LO])&0x0000F800)>>6)| \
(((src[LO])&0x000000F8)>>3); \
}
+#endif
static void
Blit_RGB888_RGB555(SDL_BlitInfo * info)
{
@@ -1237,6 +1239,7 @@ Blit_RGB888_RGB555(SDL_BlitInfo * info)
(((*src)&0x0000FC00)>>5)| \
(((*src)&0x000000F8)>>3)); \
}
+#ifndef USE_DUFFS_LOOP
#define RGB888_RGB565_TWO(dst, src) { \
*(Uint32 *)(dst) = (((((src[HI])&0x00F80000)>>8)| \
(((src[HI])&0x0000FC00)>>5)| \
@@ -1245,6 +1248,7 @@ Blit_RGB888_RGB555(SDL_BlitInfo * info)
(((src[LO])&0x0000FC00)>>5)| \
(((src[LO])&0x000000F8)>>3); \
}
+#endif
static void
Blit_RGB888_RGB565(SDL_BlitInfo * info)
{
@@ -2459,6 +2463,9 @@ BlitNto2101010(SDL_BlitInfo * info)
}
/* Normal N to N optimized blitters */
+#define NO_ALPHA 1
+#define SET_ALPHA 2
+#define COPY_ALPHA 4
struct blit_table
{
Uint32 srcR, srcG, srcB;
@@ -2466,8 +2473,7 @@ struct blit_table
Uint32 dstR, dstG, dstB;
Uint32 blit_features;
SDL_BlitFunc blitfunc;
- enum
- { NO_ALPHA = 1, SET_ALPHA = 2, COPY_ALPHA = 4 } alpha;
+ Uint32 alpha; // bitwise NO_ALPHA, SET_ALPHA, COPY_ALPHA
};
static const struct blit_table normal_blit_1[] = {
/* Default for 8-bit RGB source, never optimized */
diff --git a/src/video/x11/SDL_x11opengles.h b/src/video/x11/SDL_x11opengles.h
index 716e6e6..5ce7480 100644
--- a/src/video/x11/SDL_x11opengles.h
+++ b/src/video/x11/SDL_x11opengles.h
@@ -30,6 +30,9 @@
typedef struct SDL_PrivateGLESData
{
+ /* 1401 If the struct-declaration-list contains no named members, the behavior is undefined. */
+ /* warning: empty struct has size 0 in C, size 1 in C++ [-Wc++-compat] */
+ int dummy;
} SDL_PrivateGLESData;
/* OpenGLES functions */