kopia lustrzana https://github.com/gopro/gpr
INFRA: make __attribute__((fallthrough)) more portable
rodzic
849a460ab6
commit
be90183cc3
|
@ -34,6 +34,12 @@
|
||||||
#define PTRFASTCALL __attribute__((regparm(3)))
|
#define PTRFASTCALL __attribute__((regparm(3)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && __GNUC__ >= 7 || defined(__clang__) && __clang_major__ >= 10
|
||||||
|
#define FALL_THROUGH __attribute__ ((fallthrough))
|
||||||
|
#else
|
||||||
|
#define FALL_THROUGH ((void)0)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Using __fastcall seems to have an unexpected negative effect under
|
/* Using __fastcall seems to have an unexpected negative effect under
|
||||||
MS VC++, especially for function pointers, so we won't use it for
|
MS VC++, especially for function pointers, so we won't use it for
|
||||||
now on that platform. It may be reconsidered for a future release
|
now on that platform. It may be reconsidered for a future release
|
||||||
|
|
|
@ -1502,7 +1502,7 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
|
||||||
errorCode = XML_ERROR_NO_MEMORY;
|
errorCode = XML_ERROR_NO_MEMORY;
|
||||||
return XML_STATUS_ERROR;
|
return XML_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
__attribute__((fallthrough));
|
FALL_THROUGH;
|
||||||
default:
|
default:
|
||||||
ps_parsing = XML_PARSING;
|
ps_parsing = XML_PARSING;
|
||||||
}
|
}
|
||||||
|
@ -1529,7 +1529,7 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
|
||||||
case XML_INITIALIZED:
|
case XML_INITIALIZED:
|
||||||
case XML_PARSING:
|
case XML_PARSING:
|
||||||
ps_parsing = XML_FINISHED;
|
ps_parsing = XML_FINISHED;
|
||||||
__attribute__((fallthrough));
|
FALL_THROUGH;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
default:
|
default:
|
||||||
return XML_STATUS_OK;
|
return XML_STATUS_OK;
|
||||||
|
@ -1566,7 +1566,7 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
|
||||||
ps_parsing = XML_FINISHED;
|
ps_parsing = XML_FINISHED;
|
||||||
return XML_STATUS_OK;
|
return XML_STATUS_OK;
|
||||||
}
|
}
|
||||||
__attribute__((fallthrough));
|
FALL_THROUGH;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
default:
|
default:
|
||||||
result = XML_STATUS_OK;
|
result = XML_STATUS_OK;
|
||||||
|
@ -1631,7 +1631,7 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal)
|
||||||
errorCode = XML_ERROR_NO_MEMORY;
|
errorCode = XML_ERROR_NO_MEMORY;
|
||||||
return XML_STATUS_ERROR;
|
return XML_STATUS_ERROR;
|
||||||
}
|
}
|
||||||
__attribute__((fallthrough));
|
FALL_THROUGH;
|
||||||
default:
|
default:
|
||||||
ps_parsing = XML_PARSING;
|
ps_parsing = XML_PARSING;
|
||||||
}
|
}
|
||||||
|
@ -3897,7 +3897,7 @@ doProlog(XML_Parser parser,
|
||||||
handleDefault = XML_FALSE;
|
handleDefault = XML_FALSE;
|
||||||
goto alreadyChecked;
|
goto alreadyChecked;
|
||||||
}
|
}
|
||||||
__attribute__((fallthrough));
|
FALL_THROUGH;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case XML_ROLE_ENTITY_PUBLIC_ID:
|
case XML_ROLE_ENTITY_PUBLIC_ID:
|
||||||
if (!XmlIsPublicId(enc, s, next, eventPP))
|
if (!XmlIsPublicId(enc, s, next, eventPP))
|
||||||
|
@ -4200,7 +4200,7 @@ doProlog(XML_Parser parser,
|
||||||
return XML_ERROR_NO_MEMORY;
|
return XML_ERROR_NO_MEMORY;
|
||||||
declEntity->publicId = NULL;
|
declEntity->publicId = NULL;
|
||||||
}
|
}
|
||||||
__attribute__((fallthrough));
|
FALL_THROUGH;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
#endif /* XML_DTD */
|
#endif /* XML_DTD */
|
||||||
case XML_ROLE_ENTITY_SYSTEM_ID:
|
case XML_ROLE_ENTITY_SYSTEM_ID:
|
||||||
|
@ -4981,7 +4981,7 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata,
|
||||||
break;
|
break;
|
||||||
case XML_TOK_TRAILING_CR:
|
case XML_TOK_TRAILING_CR:
|
||||||
next = ptr + enc->minBytesPerChar;
|
next = ptr + enc->minBytesPerChar;
|
||||||
__attribute__((fallthrough));
|
FALL_THROUGH;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case XML_TOK_ATTRIBUTE_VALUE_S:
|
case XML_TOK_ATTRIBUTE_VALUE_S:
|
||||||
case XML_TOK_DATA_NEWLINE:
|
case XML_TOK_DATA_NEWLINE:
|
||||||
|
@ -5186,7 +5186,7 @@ storeEntityValue(XML_Parser parser,
|
||||||
break;
|
break;
|
||||||
case XML_TOK_TRAILING_CR:
|
case XML_TOK_TRAILING_CR:
|
||||||
next = entityTextPtr + enc->minBytesPerChar;
|
next = entityTextPtr + enc->minBytesPerChar;
|
||||||
__attribute__((fallthrough));
|
FALL_THROUGH;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case XML_TOK_DATA_NEWLINE:
|
case XML_TOK_DATA_NEWLINE:
|
||||||
if (pool->end == pool->ptr && !poolGrow(pool)) {
|
if (pool->end == pool->ptr && !poolGrow(pool)) {
|
||||||
|
|
|
@ -160,7 +160,7 @@ PREFIX(scanDecl)(const ENCODING *enc, const char *ptr,
|
||||||
*nextTokPtr = ptr;
|
*nextTokPtr = ptr;
|
||||||
return XML_TOK_INVALID;
|
return XML_TOK_INVALID;
|
||||||
}
|
}
|
||||||
__attribute__((fallthrough));
|
FALL_THROUGH;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case BT_S: case BT_CR: case BT_LF:
|
case BT_S: case BT_CR: case BT_LF:
|
||||||
*nextTokPtr = ptr;
|
*nextTokPtr = ptr;
|
||||||
|
@ -275,7 +275,7 @@ PREFIX(scanPi)(const ENCODING *enc, const char *ptr,
|
||||||
*nextTokPtr = ptr + MINBPC(enc);
|
*nextTokPtr = ptr + MINBPC(enc);
|
||||||
return tok;
|
return tok;
|
||||||
}
|
}
|
||||||
__attribute__((fallthrough));
|
FALL_THROUGH;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
default:
|
default:
|
||||||
*nextTokPtr = ptr;
|
*nextTokPtr = ptr;
|
||||||
|
@ -574,7 +574,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
|
||||||
return XML_TOK_INVALID;
|
return XML_TOK_INVALID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
__attribute__((fallthrough));
|
FALL_THROUGH;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case BT_EQUALS:
|
case BT_EQUALS:
|
||||||
{
|
{
|
||||||
|
@ -864,7 +864,7 @@ PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
|
||||||
return XML_TOK_INVALID;
|
return XML_TOK_INVALID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
__attribute__((fallthrough));
|
FALL_THROUGH;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case BT_AMP:
|
case BT_AMP:
|
||||||
case BT_LT:
|
case BT_LT:
|
||||||
|
@ -1023,7 +1023,7 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
|
||||||
/* indicate that this might be part of a CR/LF pair */
|
/* indicate that this might be part of a CR/LF pair */
|
||||||
return -XML_TOK_PROLOG_S;
|
return -XML_TOK_PROLOG_S;
|
||||||
}
|
}
|
||||||
__attribute__((fallthrough));
|
FALL_THROUGH;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case BT_S: case BT_LF:
|
case BT_S: case BT_LF:
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
@ -1037,7 +1037,7 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
|
||||||
/* don't split CR/LF pair */
|
/* don't split CR/LF pair */
|
||||||
if (ptr + MINBPC(enc) != end)
|
if (ptr + MINBPC(enc) != end)
|
||||||
break;
|
break;
|
||||||
__attribute__((fallthrough));
|
FALL_THROUGH;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
default:
|
default:
|
||||||
*nextTokPtr = ptr;
|
*nextTokPtr = ptr;
|
||||||
|
@ -1144,7 +1144,7 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
|
||||||
tok = XML_TOK_NMTOKEN;
|
tok = XML_TOK_NMTOKEN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
__attribute__((fallthrough));
|
FALL_THROUGH;
|
||||||
/* fall through */
|
/* fall through */
|
||||||
default:
|
default:
|
||||||
*nextTokPtr = ptr;
|
*nextTokPtr = ptr;
|
||||||
|
@ -1416,7 +1416,7 @@ PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
|
||||||
case BT_NMSTRT:
|
case BT_NMSTRT:
|
||||||
if (!(BYTE_TO_ASCII(enc, ptr) & ~0x7f))
|
if (!(BYTE_TO_ASCII(enc, ptr) & ~0x7f))
|
||||||
break;
|
break;
|
||||||
__attribute__((fallthrough));
|
FALL_THROUGH;
|
||||||
default:
|
default:
|
||||||
switch (BYTE_TO_ASCII(enc, ptr)) {
|
switch (BYTE_TO_ASCII(enc, ptr)) {
|
||||||
case 0x24: /* $ */
|
case 0x24: /* $ */
|
||||||
|
@ -1638,9 +1638,9 @@ PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2)
|
||||||
if (*ptr1++ != *ptr2++) \
|
if (*ptr1++ != *ptr2++) \
|
||||||
return 0;
|
return 0;
|
||||||
LEAD_CASE(4)
|
LEAD_CASE(4)
|
||||||
__attribute__((fallthrough));
|
FALL_THROUGH;
|
||||||
LEAD_CASE(3)
|
LEAD_CASE(3)
|
||||||
__attribute__((fallthrough));
|
FALL_THROUGH;
|
||||||
LEAD_CASE(2)
|
LEAD_CASE(2)
|
||||||
#undef LEAD_CASE
|
#undef LEAD_CASE
|
||||||
/* fall through */
|
/* fall through */
|
||||||
|
|
|
@ -90,6 +90,12 @@ extern "C"
|
||||||
#pragma GCC diagnostic ignored "-Wpadded"
|
#pragma GCC diagnostic ignored "-Wpadded"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__GNUC__) && __GNUC__ >= 7 || defined(__clang__) && __clang_major__ >= 10
|
||||||
|
#define FALL_THROUGH __attribute__ ((fallthrough))
|
||||||
|
#else
|
||||||
|
#define FALL_THROUGH ((void)0)
|
||||||
|
#endif
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
// Public interface:
|
// Public interface:
|
||||||
// ============================================================
|
// ============================================================
|
||||||
|
@ -1254,7 +1260,7 @@ int tje_encode_with_func(tje_write_func* func,
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
qt_factor = 10;
|
qt_factor = 10;
|
||||||
__attribute__((fallthrough));
|
FALL_THROUGH;
|
||||||
// don't break. fall through.
|
// don't break. fall through.
|
||||||
case 1:
|
case 1:
|
||||||
for ( i = 0; i < 64; ++i ) {
|
for ( i = 0; i < 64; ++i ) {
|
||||||
|
|
Ładowanie…
Reference in New Issue