Debian Codegraph @

gcc/testsuite/g++.dg/cpp2a/attr-likely7.C

raw
1 // { dg-do compile { target c++20 } }
2 // { dg-additional-options -fdump-tree-gimple }
3 // { dg-final { scan-tree-dump-times "hot label" 5 "gimple" } }
4 // { dg-final { scan-tree-dump-times "cold label" 3 "gimple" } }
5
6 bool b;
7
8 template <class T> int f()
9 {
10 if (b)
11 [[likely, whatever::unlikely ("abcd")]] return 0; // { dg-bogus "ignoring attribute 'unlikely' after earlier 'likely'" }
12 else // { dg-warning "attributes at the beginning of statement are ignored" "" { target *-*-* } .-1 }
13 [[unlikely, whatever2::hot]] flabel: return 1; // { dg-warning "'whatever2::hot' scoped attribute directive ignored" }
14 switch (b)
15 {
16 [[likely, whatever3::cold (1, 2, 3)]] case true: break; // { dg-warning "'whatever3::cold' scoped attribute directive ignored" }
17 };
18 return 1;
19 }
20
21 int main()
22 {
23 if (b)
24 [[whatever4::unlikely (1), likely]] return 0; // { dg-bogus "ignoring attribute 'likely' after earlier 'unlikely'" }
25 else if (b) // { dg-warning "attributes at the beginning of statement are ignored" "" { target *-*-* } .-1 }
26 [[whatever5::hot, unlikely]] elabel: // { dg-warning "'whatever5::hot' scoped attribute directive ignored" }
27 return 1;
28 else
29 [[whatever6::cold, likely]] b = false; // { dg-bogus "ignoring attribute 'likely' after earlier 'cold'" }
30 // { dg-warning "attributes at the beginning of statement are ignored" "" { target *-*-* } .-1 }
31 f<int>();
32
33 switch (b)
34 {
35 [[whatever7::unlikely (1), likely]] case true: break; // { dg-warning "'whatever7::unlikely' scoped attribute directive ignored" }
36 [[whatever8::unlikely, unlikely]] case false: break; // { dg-bogus "attribute 'unlikely' specified multiple times" }
37 }; // { dg-warning "'whatever8::unlikely' scoped attribute directive ignored" "" { target *-*-* } .-1 }
38 }