Add fallthrough attribute to pprintint.h
@@ -75,6 +75,8 @@ extern "C" {
#include <stdint.h>
#endif
+#include "pattributes.h" /* fallthrough */
+
#define PDIAGNOSTIC_IGNORE_UNUSED_FUNCTION
#include "pdiagnostic_push.h"
@@ -188,10 +190,10 @@ static int print_uint16(uint16_t n, char *p)
switch (k) {
case 5:
__print_stage();
- /* Fall through */
+ fallthrough;
case 3:
__print_stage();
- /* Fall through */
+ fallthrough;
case 1:
p[-1] = (char)n + '0';
}
@@ -199,7 +201,7 @@ static int print_uint16(uint16_t n, char *p)
switch (k) {
case 4:
__print_stage();
- /* Fall through */
+ fallthrough;
case 2:
__print_stage();
}
@@ -251,16 +253,16 @@ static int print_uint32(uint32_t n, char *p)
switch (k) {
case 9:
__print_stage();
- /* Fall through */
+ fallthrough;
case 7:
__print_stage();
- /* Fall through */
+ fallthrough;
case 5:
__print_stage();
- /* Fall through */
+ fallthrough;
case 3:
__print_stage();
- /* Fall through */
+ fallthrough;
case 1:
p[-1] = (char)n + '0';
}
@@ -268,19 +270,18 @@ static int print_uint32(uint32_t n, char *p)
switch (k) {
case 10:
__print_stage();
- /* Fall through */
+ fallthrough;
case 8:
__print_stage();
- /* Fall through */
+ fallthrough;
case 6:
__print_stage();
- /* Fall through */
+ fallthrough;
case 4:
__print_stage();
- /* Fall through */
+ fallthrough;
case 2:
__print_stage();
- /* Fall through */
}
}
return k;
@@ -335,42 +336,40 @@ static int print_uint64(uint64_t n, char *p)
p += k;
*p = '\0';
if (k & 1) {
- /* Fall through comments needed to silence gcc 7 warnings. */
switch (k) {
case 19:
__print_stage();
- /* Fall through */
+ fallthrough;
case 17:
__print_stage();
- /* Fall through */
+ fallthrough;
case 15:
__print_stage();
- /* Fall through */
+ fallthrough;
case 13:
__print_stage();
- /* Fall through */
+ fallthrough;
case 11:
__print_stage()
__print_short_stage();
}
} else {
- /* Fall through comments needed to silence gcc 7 warnings. */
switch (k) {
case 20:
__print_stage();
- /* Fall through */
+ fallthrough;
case 18:
__print_stage();
- /* Fall through */
+ fallthrough;
case 16:
__print_stage();
- /* Fall through */
+ fallthrough;
case 14:
__print_stage();
- /* Fall through */
+ fallthrough;
case 12:
__print_stage();
- /* Fall through */
+ fallthrough;
case 10:
__print_stage();
}
