Skip to content

Commit

Permalink
Fix fallthrough warning on gcc 7
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed May 21, 2017
1 parent f988566 commit 6e8a1e3
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 37 deletions.
1 change: 1 addition & 0 deletions src/flisp/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ void fl_print_child(fl_context_t *fl_ctx, ios_t *f, value_t v)
case TAG_CVALUE:
case TAG_CPRIM:
if (v == UNBOUND) { outs(fl_ctx, "#<undefined>", f); break; }
JL_FALLTHROUGH;
case TAG_VECTOR:
case TAG_CONS:
if (print_circle_prefix(fl_ctx, f, v)) break;
Expand Down
1 change: 1 addition & 0 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ static void *init_stdio_handle(uv_file fd,int readable)
}
#endif
// ...and continue on as in the UV_FILE case
JL_FALLTHROUGH;
case UV_FILE:
file = (jl_uv_file_t*)malloc(sizeof(jl_uv_file_t));
file->loop = jl_io_loop;
Expand Down
58 changes: 31 additions & 27 deletions src/support/MurmurHash3.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ void MurmurHash3_x86_32 ( const void * key, int len,

switch(len & 3)
{
case 3: k1 ^= tail[2] << 16;
case 2: k1 ^= tail[1] << 8;
case 3: k1 ^= tail[2] << 16; JL_FALLTHROUGH;
case 2: k1 ^= tail[1] << 8; JL_FALLTHROUGH;
case 1: k1 ^= tail[0];
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
};
Expand Down Expand Up @@ -204,26 +204,29 @@ void MurmurHash3_x86_128 ( const void * key, const int len,

switch(len & 15)
{
case 15: k4 ^= tail[14] << 16;
case 14: k4 ^= tail[13] << 8;
case 15: k4 ^= tail[14] << 16; JL_FALLTHROUGH;
case 14: k4 ^= tail[13] << 8; JL_FALLTHROUGH;
case 13: k4 ^= tail[12] << 0;
k4 *= c4; k4 = ROTL32(k4,18); k4 *= c1; h4 ^= k4;
JL_FALLTHROUGH;

case 12: k3 ^= tail[11] << 24;
case 11: k3 ^= tail[10] << 16;
case 10: k3 ^= tail[ 9] << 8;
case 12: k3 ^= tail[11] << 24; JL_FALLTHROUGH;
case 11: k3 ^= tail[10] << 16; JL_FALLTHROUGH;
case 10: k3 ^= tail[ 9] << 8; JL_FALLTHROUGH;
case 9: k3 ^= tail[ 8] << 0;
k3 *= c3; k3 = ROTL32(k3,17); k3 *= c4; h3 ^= k3;
JL_FALLTHROUGH;

case 8: k2 ^= tail[ 7] << 24;
case 7: k2 ^= tail[ 6] << 16;
case 6: k2 ^= tail[ 5] << 8;
case 8: k2 ^= tail[ 7] << 24; JL_FALLTHROUGH;
case 7: k2 ^= tail[ 6] << 16; JL_FALLTHROUGH;
case 6: k2 ^= tail[ 5] << 8; JL_FALLTHROUGH;
case 5: k2 ^= tail[ 4] << 0;
k2 *= c2; k2 = ROTL32(k2,16); k2 *= c3; h2 ^= k2;
JL_FALLTHROUGH;

case 4: k1 ^= tail[ 3] << 24;
case 3: k1 ^= tail[ 2] << 16;
case 2: k1 ^= tail[ 1] << 8;
case 4: k1 ^= tail[ 3] << 24; JL_FALLTHROUGH;
case 3: k1 ^= tail[ 2] << 16; JL_FALLTHROUGH;
case 2: k1 ^= tail[ 1] << 8; JL_FALLTHROUGH;
case 1: k1 ^= tail[ 0] << 0;
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
};
Expand Down Expand Up @@ -293,22 +296,23 @@ void MurmurHash3_x64_128 ( const void * key, const int len,

switch(len & 15)
{
case 15: k2 ^= ((uint64_t)(tail[14])) << 48;
case 14: k2 ^= ((uint64_t)(tail[13])) << 40;
case 13: k2 ^= ((uint64_t)(tail[12])) << 32;
case 12: k2 ^= ((uint64_t)(tail[11])) << 24;
case 11: k2 ^= ((uint64_t)(tail[10])) << 16;
case 10: k2 ^= ((uint64_t)(tail[ 9])) << 8;
case 15: k2 ^= ((uint64_t)(tail[14])) << 48; JL_FALLTHROUGH;
case 14: k2 ^= ((uint64_t)(tail[13])) << 40; JL_FALLTHROUGH;
case 13: k2 ^= ((uint64_t)(tail[12])) << 32; JL_FALLTHROUGH;
case 12: k2 ^= ((uint64_t)(tail[11])) << 24; JL_FALLTHROUGH;
case 11: k2 ^= ((uint64_t)(tail[10])) << 16; JL_FALLTHROUGH;
case 10: k2 ^= ((uint64_t)(tail[ 9])) << 8; JL_FALLTHROUGH;
case 9: k2 ^= ((uint64_t)(tail[ 8])) << 0;
k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2;

case 8: k1 ^= ((uint64_t)(tail[ 7])) << 56;
case 7: k1 ^= ((uint64_t)(tail[ 6])) << 48;
case 6: k1 ^= ((uint64_t)(tail[ 5])) << 40;
case 5: k1 ^= ((uint64_t)(tail[ 4])) << 32;
case 4: k1 ^= ((uint64_t)(tail[ 3])) << 24;
case 3: k1 ^= ((uint64_t)(tail[ 2])) << 16;
case 2: k1 ^= ((uint64_t)(tail[ 1])) << 8;
JL_FALLTHROUGH;

case 8: k1 ^= ((uint64_t)(tail[ 7])) << 56; JL_FALLTHROUGH;
case 7: k1 ^= ((uint64_t)(tail[ 6])) << 48; JL_FALLTHROUGH;
case 6: k1 ^= ((uint64_t)(tail[ 5])) << 40; JL_FALLTHROUGH;
case 5: k1 ^= ((uint64_t)(tail[ 4])) << 32; JL_FALLTHROUGH;
case 4: k1 ^= ((uint64_t)(tail[ 3])) << 24; JL_FALLTHROUGH;
case 3: k1 ^= ((uint64_t)(tail[ 2])) << 16; JL_FALLTHROUGH;
case 2: k1 ^= ((uint64_t)(tail[ 1])) << 8; JL_FALLTHROUGH;
case 1: k1 ^= ((uint64_t)(tail[ 0])) << 0;
k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1;
};
Expand Down
10 changes: 10 additions & 0 deletions src/support/dtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,14 @@ typedef enum { T_INT8, T_UINT8, T_INT16, T_UINT16, T_INT32, T_UINT32,
# define T_SIZE T_UINT32
#endif

#if defined(__GNUC__) && __GNUC__ >= 7
#define JL_FALLTHROUGH __attribute__((fallthrough))
#elif defined(__cplusplus) && defined(__clang_major__) && \
defined(__clang_minor__) && (__clang_major__ > 4 || __clang_minor__ >= 5)
// We require at least clang 3.x
#define JL_FALLTHROUGH [[clang::fallthrough]]
#else
#define JL_FALLTHROUGH
#endif

#endif /* DTYPES_H */
20 changes: 10 additions & 10 deletions src/support/utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ size_t u8_toucs(uint32_t *dest, size_t sz, const char *src, size_t srcsz)
ch = 0;
switch (nb) {
/* these fall through deliberately */
case 5: ch += (unsigned char)*src++; ch <<= 6;
case 4: ch += (unsigned char)*src++; ch <<= 6;
case 3: ch += (unsigned char)*src++; ch <<= 6;
case 2: ch += (unsigned char)*src++; ch <<= 6;
case 1: ch += (unsigned char)*src++; ch <<= 6;
case 5: ch += (unsigned char)*src++; ch <<= 6; JL_FALLTHROUGH;
case 4: ch += (unsigned char)*src++; ch <<= 6; JL_FALLTHROUGH;
case 3: ch += (unsigned char)*src++; ch <<= 6; JL_FALLTHROUGH;
case 2: ch += (unsigned char)*src++; ch <<= 6; JL_FALLTHROUGH;
case 1: ch += (unsigned char)*src++; ch <<= 6; JL_FALLTHROUGH;
case 0: ch += (unsigned char)*src++;
}
ch -= offsetsFromUTF8[nb];
Expand Down Expand Up @@ -252,11 +252,11 @@ size_t u8_strwidth(const char *s)
ch = 0;
switch (nb) {
/* these fall through deliberately */
case 5: ch += (unsigned char)*s++; ch <<= 6;
case 4: ch += (unsigned char)*s++; ch <<= 6;
case 3: ch += (unsigned char)*s++; ch <<= 6;
case 2: ch += (unsigned char)*s++; ch <<= 6;
case 1: ch += (unsigned char)*s++; ch <<= 6;
case 5: ch += (unsigned char)*s++; ch <<= 6; JL_FALLTHROUGH;
case 4: ch += (unsigned char)*s++; ch <<= 6; JL_FALLTHROUGH;
case 3: ch += (unsigned char)*s++; ch <<= 6; JL_FALLTHROUGH;
case 2: ch += (unsigned char)*s++; ch <<= 6; JL_FALLTHROUGH;
case 1: ch += (unsigned char)*s++; ch <<= 6; JL_FALLTHROUGH;
case 0: ch += (unsigned char)*s++;
}
ch -= offsetsFromUTF8[nb];
Expand Down

0 comments on commit 6e8a1e3

Please sign in to comment.