Debian Codegraph @

gcc/testsuite/c-c++-common/musttail23.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-W -Wall" } */
3
4 void bar (void);
5
6 void
7 foo (int x)
8 {
9 __attribute__((musttail)); /* { dg-warning "empty declaration" "" { target c } } */
10 /* { dg-warning "attributes at the beginning of statement are ignored" "" { target c++ } .-1 } */
11 if (x == 1)
12 __attribute__((musttail (1))) return bar (); /* { dg-error "'musttail' attribute does not take any arguments" } */
13 if (x == 2)
14 __attribute__((musttail (1, "", 3))) return bar (); /* { dg-error "'musttail' attribute does not take any arguments" } */
15 if (x == 3)
16 [[gnu::musttail (1)]] return bar (); /* { dg-error "'musttail' attribute does not take any arguments" } */
17 /* { dg-error "expected" "" { target c } .-1 } */
18 if (x == 4)
19 [[gnu::musttail (1, "", 3)]] return bar (); /* { dg-error "'musttail' attribute does not take any arguments" } */
20 /* { dg-error "expected" "" { target c } .-1 } */
21 if (x == 3)
22 [[clang::musttail (1)]] return bar (); /* { dg-error "'musttail' attribute does not take any arguments" } */
23 /* { dg-error "expected" "" { target c } .-1 } */
24 if (x == 4)
25 [[clang::musttail (1, "", 3)]] return bar (); /* { dg-error "'musttail' attribute does not take any arguments" } */
26 /* { dg-error "expected" "" { target c } .-1 } */
27 if (x == 5)
28 __attribute__((fallthrough, musttail)) return bar (); /* { dg-warning "attribute 'musttail' mixed with other attributes on 'return' statement" "" { target c } } */
29 /* { dg-warning "attributes at the beginning of statement are ignored" "" { target c++ } .-1 } */
30
31 if (x == 6)
32 [[fallthrough]] [[gnu::musttail]] return bar (); /* { dg-warning "'fallthrough' attribute ignored" "" { target c } } */
33 /* { dg-warning "attributes at the beginning of statement are ignored" "" { target c++ } .-1 } */
34 if (x == 7)
35 [[clang::musttail, fallthrough]] return bar (); /* { dg-warning "'fallthrough' attribute ignored" "" { target c } } */
36 /* { dg-warning "attributes at the beginning of statement are ignored" "" { target c++ } .-1 } */
37 if (x == 8)
38 __attribute__((musttail, musttail)) return bar ();
39 if (x == 9)
40 [[gnu::musttail, gnu::musttail]] return bar ();
41 if (x == 10)
42 [[clang::musttail]] [[clang::musttail]] return bar ();
43 if (x == 11)
44 [[clang::musttail]] [[gnu::musttail]] return bar ();
45 }