summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWerner Lemberg <wl@gnu.org>2023-02-08 19:36:10 +0100
committerWerner Lemberg <wl@gnu.org>2023-02-08 21:09:32 +0100
commitac5babe87629107c43f627e2cd17c6cf4f2ecd43 (patch)
tree1d44cc939839be7839237e18cd06f92d16f3da20
parentbe724c8142a3f5381fac436becb842f808f82259 (diff)
downloadfreetype2-ac5babe87629107c43f627e2cd17c6cf4f2ecd43.tar.gz
Fix 'fall-through' warning messages.
Modern compilers get more insistent on that... * include/freetype/internal/compiler-macros.h (FALL_THROUGH): Define. * src/*: Use it instead of `/* fall through */` comments.
-rw-r--r--include/freetype/internal/compiler-macros.h13
-rw-r--r--src/base/ftobjs.c2
-rw-r--r--src/lzw/ftzopen.c4
-rw-r--r--src/psaux/afmparse.c2
-rw-r--r--src/sdf/ftsdf.c4
-rw-r--r--src/sfnt/pngshim.c3
-rw-r--r--src/sfnt/sfdriver.c28
-rw-r--r--src/sfnt/ttsbit.c2
-rw-r--r--src/smooth/ftgrays.c30
-rw-r--r--src/type42/t42parse.c4
10 files changed, 53 insertions, 39 deletions
diff --git a/include/freetype/internal/compiler-macros.h b/include/freetype/internal/compiler-macros.h
index c5de88580..9848174a7 100644
--- a/include/freetype/internal/compiler-macros.h
+++ b/include/freetype/internal/compiler-macros.h
@@ -36,6 +36,19 @@ FT_BEGIN_HEADER
# endif
#endif
+ /* Newer compilers warn for fall-through case statements. */
+#ifndef FALL_THROUGH
+# if ( defined( __STDC_VERSION__ ) && __STDC_VERSION__ > 201710L ) || \
+ ( defined( __cplusplus ) && __cplusplus > 201402L )
+# define FALL_THROUGH [[__fallthrough__]]
+# elif ( defined( __GNUC__ ) && __GNUC__ >= 7 ) || \
+ ( defined( __clang__ ) && __clang_major__ >= 10 )
+# define FALL_THROUGH __attribute__(( __fallthrough__ ))
+# else
+# define FALL_THROUGH ( (void)0 )
+# endif
+#endif
+
/*
* When defining a macro that expands to a non-trivial C statement, use
* FT_BEGIN_STMNT and FT_END_STMNT to enclose the macro's body. This
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 03487f48b..ad6ef0ae1 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -508,7 +508,7 @@
case FT_PIXEL_MODE_LCD_V:
height *= 3;
- /* fall through */
+ FALL_THROUGH;
case FT_PIXEL_MODE_GRAY:
default:
diff --git a/src/lzw/ftzopen.c b/src/lzw/ftzopen.c
index 1afec2a03..e680c4de5 100644
--- a/src/lzw/ftzopen.c
+++ b/src/lzw/ftzopen.c
@@ -315,7 +315,7 @@
state->phase = FT_LZW_PHASE_CODE;
}
- /* fall-through */
+ FALL_THROUGH;
case FT_LZW_PHASE_CODE:
{
@@ -373,7 +373,7 @@
state->phase = FT_LZW_PHASE_STACK;
}
- /* fall-through */
+ FALL_THROUGH;
case FT_LZW_PHASE_STACK:
{
diff --git a/src/psaux/afmparse.c b/src/psaux/afmparse.c
index 9830970bc..e97abb09e 100644
--- a/src/psaux/afmparse.c
+++ b/src/psaux/afmparse.c
@@ -1061,7 +1061,7 @@
if ( error )
goto Fail;
/* we only support kern data, so ... */
- /* fall through */
+ FALL_THROUGH;
case AFM_TOKEN_ENDFONTMETRICS:
return FT_Err_Ok;
diff --git a/src/sdf/ftsdf.c b/src/sdf/ftsdf.c
index 5faa74351..26a6d00e4 100644
--- a/src/sdf/ftsdf.c
+++ b/src/sdf/ftsdf.c
@@ -871,7 +871,7 @@
cbox.yMax = edge.control_b.y;
is_set = 1;
- /* fall through */
+ FALL_THROUGH;
case SDF_EDGE_CONIC:
if ( is_set )
@@ -899,7 +899,7 @@
is_set = 1;
}
- /* fall through */
+ FALL_THROUGH;
case SDF_EDGE_LINE:
if ( is_set )
diff --git a/src/sfnt/pngshim.c b/src/sfnt/pngshim.c
index 2aeba3592..423b07b02 100644
--- a/src/sfnt/pngshim.c
+++ b/src/sfnt/pngshim.c
@@ -407,7 +407,8 @@
switch ( color_type )
{
default:
- /* Shouldn't happen, but fall through. */
+ /* Shouldn't happen, but ... */
+ FALL_THROUGH;
case PNG_COLOR_TYPE_RGB_ALPHA:
png_set_read_user_transform_fn( png, premultiply_data );
diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c
index 0095b8297..762883db5 100644
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -378,61 +378,61 @@
{
case 15:
k4 ^= (FT_UInt32)tail[14] << 16;
- /* fall through */
+ FALL_THROUGH;
case 14:
k4 ^= (FT_UInt32)tail[13] << 8;
- /* fall through */
+ FALL_THROUGH;
case 13:
k4 ^= (FT_UInt32)tail[12];
k4 *= c4;
k4 = ROTL32( k4, 18 );
k4 *= c1;
h4 ^= k4;
- /* fall through */
+ FALL_THROUGH;
case 12:
k3 ^= (FT_UInt32)tail[11] << 24;
- /* fall through */
+ FALL_THROUGH;
case 11:
k3 ^= (FT_UInt32)tail[10] << 16;
- /* fall through */
+ FALL_THROUGH;
case 10:
k3 ^= (FT_UInt32)tail[9] << 8;
- /* fall through */
+ FALL_THROUGH;
case 9:
k3 ^= (FT_UInt32)tail[8];
k3 *= c3;
k3 = ROTL32( k3, 17 );
k3 *= c4;
h3 ^= k3;
- /* fall through */
+ FALL_THROUGH;
case 8:
k2 ^= (FT_UInt32)tail[7] << 24;
- /* fall through */
+ FALL_THROUGH;
case 7:
k2 ^= (FT_UInt32)tail[6] << 16;
- /* fall through */
+ FALL_THROUGH;
case 6:
k2 ^= (FT_UInt32)tail[5] << 8;
- /* fall through */
+ FALL_THROUGH;
case 5:
k2 ^= (FT_UInt32)tail[4];
k2 *= c2;
k2 = ROTL32( k2, 16 );
k2 *= c3;
h2 ^= k2;
- /* fall through */
+ FALL_THROUGH;
case 4:
k1 ^= (FT_UInt32)tail[3] << 24;
- /* fall through */
+ FALL_THROUGH;
case 3:
k1 ^= (FT_UInt32)tail[2] << 16;
- /* fall through */
+ FALL_THROUGH;
case 2:
k1 ^= (FT_UInt32)tail[1] << 8;
- /* fall through */
+ FALL_THROUGH;
case 1:
k1 ^= (FT_UInt32)tail[0];
k1 *= c1;
diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c
index 015c250b2..9c865e4b2 100644
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -1193,7 +1193,7 @@
goto Fail;
p += 1; /* skip padding */
- /* fall-through */
+ FALL_THROUGH;
case 9:
loader = tt_sbit_decoder_load_compound;
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index b4cbb80b8..d9f20eef1 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -418,21 +418,21 @@ typedef ptrdiff_t FT_PtrDist;
/* It is faster to write small spans byte-by-byte than calling */
/* `memset'. This is mainly due to the cost of the function call. */
-#define FT_GRAY_SET( d, s, count ) \
- FT_BEGIN_STMNT \
- unsigned char* q = d; \
- switch ( count ) \
- { \
- case 7: *q++ = (unsigned char)s; /* fall through */ \
- case 6: *q++ = (unsigned char)s; /* fall through */ \
- case 5: *q++ = (unsigned char)s; /* fall through */ \
- case 4: *q++ = (unsigned char)s; /* fall through */ \
- case 3: *q++ = (unsigned char)s; /* fall through */ \
- case 2: *q++ = (unsigned char)s; /* fall through */ \
- case 1: *q = (unsigned char)s; /* fall through */ \
- case 0: break; \
- default: FT_MEM_SET( d, s, count ); \
- } \
+#define FT_GRAY_SET( d, s, count ) \
+ FT_BEGIN_STMNT \
+ unsigned char* q = d; \
+ switch ( count ) \
+ { \
+ case 7: *q++ = (unsigned char)s; FALL_THROUGH; \
+ case 6: *q++ = (unsigned char)s; FALL_THROUGH; \
+ case 5: *q++ = (unsigned char)s; FALL_THROUGH; \
+ case 4: *q++ = (unsigned char)s; FALL_THROUGH; \
+ case 3: *q++ = (unsigned char)s; FALL_THROUGH; \
+ case 2: *q++ = (unsigned char)s; FALL_THROUGH; \
+ case 1: *q = (unsigned char)s; FALL_THROUGH; \
+ case 0: break; \
+ default: FT_MEM_SET( d, s, count ); \
+ } \
FT_END_STMNT
diff --git a/src/type42/t42parse.c b/src/type42/t42parse.c
index 78cc8fa1d..6d765c8c1 100644
--- a/src/type42/t42parse.c
+++ b/src/type42/t42parse.c
@@ -733,7 +733,7 @@
ttf_reserved ) )
goto Fail;
}
- /* fall through */
+ FALL_THROUGH;
case BEFORE_TABLE_DIR:
/* the offset table is read; read the table directory */
@@ -785,7 +785,7 @@
ttf_reserved ) )
goto Fail;
}
- /* fall through */
+ FALL_THROUGH;
case OTHER_TABLES:
/* all other tables are just copied */