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.
This commit is contained in:
Werner Lemberg 2023-02-08 19:36:10 +01:00
parent be724c8142
commit ac5babe876
10 changed files with 53 additions and 39 deletions

View File

@ -34,6 +34,19 @@ FT_BEGIN_HEADER
# if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 )
# pragma set woff 3505
# 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
/*

View File

@ -508,7 +508,7 @@
case FT_PIXEL_MODE_LCD_V:
height *= 3;
/* fall through */
FALL_THROUGH;
case FT_PIXEL_MODE_GRAY:
default:

View File

@ -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:
{

View File

@ -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;

View File

@ -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 )

View File

@ -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 );

View File

@ -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;

View File

@ -1193,7 +1193,7 @@
goto Fail;
p += 1; /* skip padding */
/* fall-through */
FALL_THROUGH;
case 9:
loader = tt_sbit_decoder_load_compound;

View File

@ -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

View File

@ -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 */