gcc/testsuite/g++.dg/warn/Wunused-20.C
raw| 1 | // PR c++/114104 |
| 2 | // { dg-additional-options "-Wunused-value" } |
| 3 | |
| 4 | bool f(); |
| 5 | struct A { int i; }; |
| 6 | A& g(); |
| 7 | |
| 8 | void h() { |
| 9 | !f(); // { dg-warning "value computed is not used" } |
| 10 | &g().i; // { dg-warning "value computed is not used" } |
| 11 | } |
| 12 | |
| 13 | #if __cplusplus >= 202002L |
| 14 | [[nodiscard]] bool operator==(A&, int); |
| 15 | |
| 16 | void h(A a) { |
| 17 | a != 0; // { dg-warning "value computed is not used" "" { target c++20 } } |
| 18 | } |
| 19 | #endif |