ROSE
0.11.145.247
Toggle main menu visibility
Main Page
Related Pages
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
a
c
d
g
h
i
l
m
n
s
t
u
v
Typedefs
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
x
Enumerations
a
b
c
d
e
f
i
k
l
m
o
p
s
t
v
w
x
Enumerator
a
b
c
d
e
f
h
i
l
m
n
o
p
s
t
u
v
w
y
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
i
l
m
n
o
p
r
s
t
u
v
w
x
y
Related Symbols
b
i
o
Files
File List
Examples
src
util
ROSE_FALLTHROUGH.h
1
#ifndef ROSE_FALLTHROUGH_H
2
#define ROSE_FALLTHROUGH_H
3
4
// Marks case branches that fall through to the next case, so that the compiler does not generate
5
// "this statement may fall through" warnings (i.e., GCC).
6
//
7
// | 1|int foo(int x) {
8
// | 2| int res = 0;
9
// | 3| switch(x) {
10
// | 4| case 1: ++res;
11
// | 5| default: ++res; break;
12
// | 6| }
13
// | 7| return res;
14
// | 8|}
15
//
16
// The compiler will emit a implicit-fallthrough warning for the end of 'case 0:' at line 4.
17
//
18
// The best way is to use C++17 attributes.
19
//
20
// | 1|int foo(int x) {
21
// | 2| int res = 0;
22
// | 3| switch(x) {
23
// | 4| case 1: ++res; [[fallthrough]]
24
// | 5| default: ++res; break;
25
// | 6| }
26
// | 7| return res;
27
// | 8|}
28
//
29
// Until we support C++17 in ROSE fully, we can rely on older attributes for the GNU compiler.
30
// [[gnu::fallthrough]]
31
//
32
// | 1|int foo(int x) {
33
// | 2| int res = 0;
34
// | 3| switch(x) {
35
// | 4| case 1: ++res; ROSE_FALLTHROUGH
36
// | 5| default: ++res; break;
37
// | 6| }
38
// | 7| return res;
39
// | 8|}
40
//
41
// reference for gcc: https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7
42
43
44
#if __cplusplus >= 201703L
45
#define ROSE_FALLTHROUGH [[fallthrough]]
46
#elif defined __GNUC__
47
#define ROSE_FALLTHROUGH [[gnu::fallthrough]]
48
#else
49
// this may not work as intended
50
#define ROSE_FALLTHROUGH
/* FALL THROUGH */
51
#endif
52
53
54
#endif
Generated on Mon Mar 31 2025 00:23:43 for ROSE by
1.9.8