mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
Merge branch 'wip/otte/fallthrough' into 'master'
Add G_GNUC_FALLTHROUGH for __attribute__(fallthrough)) See merge request GNOME/glib!296
This commit is contained in:
commit
98f326a020
@ -438,6 +438,7 @@ G_GNUC_DEPRECATED_FOR
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
G_GNUC_NORETURN
|
||||
G_GNUC_FALLTHROUGH
|
||||
G_GNUC_UNUSED
|
||||
G_GNUC_PRINTF
|
||||
G_GNUC_SCANF
|
||||
|
@ -166,9 +166,11 @@ test_data_array (guchar *buffer, gsize len,
|
||||
case TEST_DATA_INT16:
|
||||
case TEST_DATA_UINT16:
|
||||
g_assert_cmpint (len % 2, ==, 0);
|
||||
G_GNUC_FALLTHROUGH;
|
||||
case TEST_DATA_INT32:
|
||||
case TEST_DATA_UINT32:
|
||||
g_assert_cmpint (len % 4, ==, 0);
|
||||
G_GNUC_FALLTHROUGH;
|
||||
case TEST_DATA_INT64:
|
||||
case TEST_DATA_UINT64:
|
||||
g_assert_cmpint (len % 8, ==, 0);
|
||||
|
@ -33,12 +33,14 @@ cook_piece (void)
|
||||
{
|
||||
case 26:
|
||||
buffer[i++] = '\n';
|
||||
G_GNUC_FALLTHROUGH;
|
||||
case 27:
|
||||
buffer[i++] = '\r';
|
||||
break;
|
||||
|
||||
case 28:
|
||||
buffer[i++] = '\r';
|
||||
G_GNUC_FALLTHROUGH;
|
||||
case 29:
|
||||
buffer[i++] = '\n';
|
||||
break;
|
||||
|
16
glib/docs.c
16
glib/docs.c
@ -2280,6 +2280,22 @@
|
||||
* See the GNU C documentation for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* G_GNUC_FALLTHROUGH:
|
||||
*
|
||||
* Expands to the GNU C fallthrough statement attribute if the compiler is gcc.
|
||||
* This allows declaring case statement to explicitly fall through in switch
|
||||
* statements. To enable this feature, use -Wimplicit-fallthrough during
|
||||
* compilation.
|
||||
*
|
||||
* Put the attribute right before the case statement you want to fall through
|
||||
* to.
|
||||
*
|
||||
* See the GNU C documentation for more details.
|
||||
*
|
||||
* Since: 2.60
|
||||
*/
|
||||
|
||||
/**
|
||||
* G_GNUC_UNUSED:
|
||||
*
|
||||
|
@ -170,8 +170,11 @@ g_base64_encode_step (const guchar *in,
|
||||
/* len can only be 0 1 or 2 */
|
||||
switch(len)
|
||||
{
|
||||
case 2: *saveout++ = *inptr++;
|
||||
case 1: *saveout++ = *inptr++;
|
||||
case 2:
|
||||
*saveout++ = *inptr++;
|
||||
G_GNUC_FALLTHROUGH;
|
||||
case 1:
|
||||
*saveout++ = *inptr++;
|
||||
}
|
||||
((char *)save)[0] += len;
|
||||
}
|
||||
|
@ -788,7 +788,8 @@ g_convert_with_fallback (const gchar *str,
|
||||
inbytes_remaining = strlen (p);
|
||||
break;
|
||||
}
|
||||
/* fall thru if p is NULL */
|
||||
/* if p is null */
|
||||
G_GNUC_FALLTHROUGH;
|
||||
default:
|
||||
{
|
||||
int errsv = errno;
|
||||
|
@ -191,6 +191,12 @@
|
||||
#define G_GNUC_NO_INSTRUMENT
|
||||
#endif /* !__GNUC__ */
|
||||
|
||||
#if __GNUC__ > 6
|
||||
#define G_GNUC_FALLTHROUGH __attribute__((fallthrough))
|
||||
#else
|
||||
#define G_GNUC_FALLTHROUGH
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
|
||||
#define G_GNUC_DEPRECATED __attribute__((__deprecated__))
|
||||
#else
|
||||
|
@ -2872,6 +2872,8 @@ failure:
|
||||
case G_MARKUP_COLLECT_STRDUP:
|
||||
if (written)
|
||||
g_free (*(char **) ptr);
|
||||
*(char **) ptr = NULL;
|
||||
break;
|
||||
|
||||
case G_MARKUP_COLLECT_STRING:
|
||||
*(char **) ptr = NULL;
|
||||
|
@ -2537,6 +2537,7 @@ expand_escape (const gchar *replacement,
|
||||
base = 8;
|
||||
p = g_utf8_next_char (p);
|
||||
}
|
||||
G_GNUC_FALLTHROUGH;
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
|
@ -372,6 +372,8 @@ parse_constant_offset (const gchar *name,
|
||||
*offset = -*offset;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
|
||||
default:
|
||||
return FALSE;
|
||||
|
@ -210,10 +210,7 @@ token_stream_prepare (TokenStream *stream)
|
||||
break;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* ↓↓↓ */
|
||||
}
|
||||
G_GNUC_FALLTHROUGH;
|
||||
|
||||
case 'a': /* 'b' */ case 'c': case 'd': case 'e': case 'f':
|
||||
case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
|
||||
@ -1646,6 +1643,8 @@ string_parse (TokenStream *stream,
|
||||
case '\n': i++; continue;
|
||||
}
|
||||
|
||||
G_GNUC_FALLTHROUGH;
|
||||
|
||||
default:
|
||||
str[j++] = token[i++];
|
||||
}
|
||||
@ -1773,6 +1772,8 @@ bytestring_parse (TokenStream *stream,
|
||||
case '\n': i++; continue;
|
||||
}
|
||||
|
||||
G_GNUC_FALLTHROUGH;
|
||||
|
||||
default:
|
||||
str[j++] = token[i++];
|
||||
}
|
||||
|
@ -344,6 +344,7 @@ if cc.get_id() == 'gcc' or cc.get_id() == 'clang'
|
||||
test_c_args = [
|
||||
'-Wall',
|
||||
'-Wduplicated-branches',
|
||||
'-Wimplicit-fallthrough',
|
||||
'-Wmisleading-indentation',
|
||||
'-Wstrict-prototypes',
|
||||
'-Wunused',
|
||||
|
Loading…
Reference in New Issue
Block a user