| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-require-effective-target pthread } */ |
| 3 |
/* { dg-options "-Og --coverage -pthread -fdump-tree-optimized -std=c++17" } */ |
| 4 |
using uint16_t = unsigned short; |
| 5 |
|
| 6 |
struct a { |
| 7 |
uint16_t b = 0; |
| 8 |
}; |
| 9 |
struct c { |
| 10 |
short d; |
| 11 |
}; |
| 12 |
class e { |
| 13 |
public: |
| 14 |
void f(); |
| 15 |
void init_session(c); |
| 16 |
}; |
| 17 |
|
| 18 |
auto htons = [](uint16_t s) { |
| 19 |
if (__builtin_constant_p(s)) { |
| 20 |
return uint16_t(uint16_t(s >> 8) | uint16_t(s << 8)); |
| 21 |
} |
| 22 |
return uint16_t(uint16_t(s >> 8) | uint16_t(s << 8)); |
| 23 |
}; |
| 24 |
|
| 25 |
struct g { |
| 26 |
e h; |
| 27 |
void i(a k) { |
| 28 |
h.f(); |
| 29 |
auto j = c(); |
| 30 |
j.d = htons(k.b); |
| 31 |
h.init_session(j); |
| 32 |
} |
| 33 |
}; |
| 34 |
|
| 35 |
void test() { |
| 36 |
g().i({}); |
| 37 |
} |
| 38 |
|
| 39 |
/* { dg-final { scan-tree-dump-not "builtin_unreachable" "optimized"} } */ |