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)))
|
||||
#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
|
||||
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
|
||||
|
|
|
@ -1502,7 +1502,7 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
|
|||
errorCode = XML_ERROR_NO_MEMORY;
|
||||
return XML_STATUS_ERROR;
|
||||
}
|
||||
__attribute__((fallthrough));
|
||||
FALL_THROUGH;
|
||||
default:
|
||||
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_PARSING:
|
||||
ps_parsing = XML_FINISHED;
|
||||
__attribute__((fallthrough));
|
||||
FALL_THROUGH;
|
||||
/* fall through */
|
||||
default:
|
||||
return XML_STATUS_OK;
|
||||
|
@ -1566,7 +1566,7 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
|
|||
ps_parsing = XML_FINISHED;
|
||||
return XML_STATUS_OK;
|
||||
}
|
||||
__attribute__((fallthrough));
|
||||
FALL_THROUGH;
|
||||
/* fall through */
|
||||
default:
|
||||
result = XML_STATUS_OK;
|
||||
|
@ -1631,7 +1631,7 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal)
|
|||
errorCode = XML_ERROR_NO_MEMORY;
|
||||
return XML_STATUS_ERROR;
|
||||
}
|
||||
__attribute__((fallthrough));
|
||||
FALL_THROUGH;
|
||||
default:
|
||||
ps_parsing = XML_PARSING;
|
||||
}
|
||||
|
@ -3897,7 +3897,7 @@ doProlog(XML_Parser parser,
|
|||
handleDefault = XML_FALSE;
|
||||
goto alreadyChecked;
|
||||
}
|
||||
__attribute__((fallthrough));
|
||||
FALL_THROUGH;
|
||||
/* fall through */
|
||||
case XML_ROLE_ENTITY_PUBLIC_ID:
|
||||
if (!XmlIsPublicId(enc, s, next, eventPP))
|
||||
|
@ -4200,7 +4200,7 @@ doProlog(XML_Parser parser,
|
|||
return XML_ERROR_NO_MEMORY;
|
||||
declEntity->publicId = NULL;
|
||||
}
|
||||
__attribute__((fallthrough));
|
||||
FALL_THROUGH;
|
||||
/* fall through */
|
||||
#endif /* XML_DTD */
|
||||
case XML_ROLE_ENTITY_SYSTEM_ID:
|
||||
|
@ -4981,7 +4981,7 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata,
|
|||
break;
|
||||
case XML_TOK_TRAILING_CR:
|
||||
next = ptr + enc->minBytesPerChar;
|
||||
__attribute__((fallthrough));
|
||||
FALL_THROUGH;
|
||||
/* fall through */
|
||||
case XML_TOK_ATTRIBUTE_VALUE_S:
|
||||
case XML_TOK_DATA_NEWLINE:
|
||||
|
@ -5186,7 +5186,7 @@ storeEntityValue(XML_Parser parser,
|
|||
break;
|
||||
case XML_TOK_TRAILING_CR:
|
||||
next = entityTextPtr + enc->minBytesPerChar;
|
||||
__attribute__((fallthrough));
|
||||
FALL_THROUGH;
|
||||
/* fall through */
|
||||
case XML_TOK_DATA_NEWLINE:
|
||||
if (pool->end == pool->ptr && !poolGrow(pool)) {
|
||||
|
|
|
@ -160,7 +160,7 @@ PREFIX(scanDecl)(const ENCODING *enc, const char *ptr,
|
|||
*nextTokPtr = ptr;
|
||||
return XML_TOK_INVALID;
|
||||
}
|
||||
__attribute__((fallthrough));
|
||||
FALL_THROUGH;
|
||||
/* fall through */
|
||||
case BT_S: case BT_CR: case BT_LF:
|
||||
*nextTokPtr = ptr;
|
||||
|
@ -275,7 +275,7 @@ PREFIX(scanPi)(const ENCODING *enc, const char *ptr,
|
|||
*nextTokPtr = ptr + MINBPC(enc);
|
||||
return tok;
|
||||
}
|
||||
__attribute__((fallthrough));
|
||||
FALL_THROUGH;
|
||||
/* fall through */
|
||||
default:
|
||||
*nextTokPtr = ptr;
|
||||
|
@ -574,7 +574,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
|
|||
return XML_TOK_INVALID;
|
||||
}
|
||||
}
|
||||
__attribute__((fallthrough));
|
||||
FALL_THROUGH;
|
||||
/* fall through */
|
||||
case BT_EQUALS:
|
||||
{
|
||||
|
@ -864,7 +864,7 @@ PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
|
|||
return XML_TOK_INVALID;
|
||||
}
|
||||
}
|
||||
__attribute__((fallthrough));
|
||||
FALL_THROUGH;
|
||||
/* fall through */
|
||||
case BT_AMP:
|
||||
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 */
|
||||
return -XML_TOK_PROLOG_S;
|
||||
}
|
||||
__attribute__((fallthrough));
|
||||
FALL_THROUGH;
|
||||
/* fall through */
|
||||
case BT_S: case BT_LF:
|
||||
for (;;) {
|
||||
|
@ -1037,7 +1037,7 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
|
|||
/* don't split CR/LF pair */
|
||||
if (ptr + MINBPC(enc) != end)
|
||||
break;
|
||||
__attribute__((fallthrough));
|
||||
FALL_THROUGH;
|
||||
/* fall through */
|
||||
default:
|
||||
*nextTokPtr = ptr;
|
||||
|
@ -1144,7 +1144,7 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
|
|||
tok = XML_TOK_NMTOKEN;
|
||||
break;
|
||||
}
|
||||
__attribute__((fallthrough));
|
||||
FALL_THROUGH;
|
||||
/* fall through */
|
||||
default:
|
||||
*nextTokPtr = ptr;
|
||||
|
@ -1416,7 +1416,7 @@ PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
|
|||
case BT_NMSTRT:
|
||||
if (!(BYTE_TO_ASCII(enc, ptr) & ~0x7f))
|
||||
break;
|
||||
__attribute__((fallthrough));
|
||||
FALL_THROUGH;
|
||||
default:
|
||||
switch (BYTE_TO_ASCII(enc, ptr)) {
|
||||
case 0x24: /* $ */
|
||||
|
@ -1638,9 +1638,9 @@ PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2)
|
|||
if (*ptr1++ != *ptr2++) \
|
||||
return 0;
|
||||
LEAD_CASE(4)
|
||||
__attribute__((fallthrough));
|
||||
FALL_THROUGH;
|
||||
LEAD_CASE(3)
|
||||
__attribute__((fallthrough));
|
||||
FALL_THROUGH;
|
||||
LEAD_CASE(2)
|
||||
#undef LEAD_CASE
|
||||
/* fall through */
|
||||
|
|
|
@ -90,6 +90,12 @@ extern "C"
|
|||
#pragma GCC diagnostic ignored "-Wpadded"
|
||||
#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:
|
||||
// ============================================================
|
||||
|
@ -1254,7 +1260,7 @@ int tje_encode_with_func(tje_write_func* func,
|
|||
break;
|
||||
case 2:
|
||||
qt_factor = 10;
|
||||
__attribute__((fallthrough));
|
||||
FALL_THROUGH;
|
||||
// don't break. fall through.
|
||||
case 1:
|
||||
for ( i = 0; i < 64; ++i ) {
|
||||
|
|
Ładowanie…
Reference in New Issue