| 1 |
// Verify our -Wparentheses warning handles "boolish" class types |
| 2 |
// such as std::vector<bool>'s reference type the same as ordinary |
| 3 |
// bool. |
| 4 |
// { dg-additional-options "-Wparentheses" } |
| 5 |
// { dg-skip-if "requires hosted libstdc++ for vector" { ! hostedlib } } |
| 6 |
|
| 7 |
#include <vector> |
| 8 |
|
| 9 |
void f(std::vector<bool> v, int i) { |
| 10 |
bool b; |
| 11 |
b = v[i] = true; |
| 12 |
b = v[i] = v[i+1]; |
| 13 |
|
| 14 |
if (v[i] = 42) { } // { dg-message "parentheses" } |
| 15 |
if (v[i] = v[i+1]) { } // { dg-message "parentheses" } |
| 16 |
|
| 17 |
if ((v[i] = 42)) { } |
| 18 |
if ((v[i] = v[i+1])) { } |
| 19 |
} |
| 20 |
|
| 21 |
template<class> |
| 22 |
void ft(std::vector<bool> v, int i) { |
| 23 |
bool b; |
| 24 |
b = v[i] = true; |
| 25 |
b = v[i] = v[i+1]; |
| 26 |
|
| 27 |
if (v[i] = 42) { } // { dg-message "parentheses" } |
| 28 |
if (v[i] = v[i+1]) { } // { dg-message "parentheses" } |
| 29 |
|
| 30 |
if ((v[i] = 42)) { } |
| 31 |
if ((v[i] = v[i+1])) { } |
| 32 |
} |