Debian Codegraph @

gcc/testsuite/g++.dg/warn/Wparentheses-32.C

raw
1 // Verify we issue -Wparentheses warnings at template definition time
2 // (for suitable non-dependent expressions).
3 // { dg-additional-options "-Wparentheses" }
4
5 struct X { operator bool(); };
6 struct Y { Y& operator=(const Y&); operator bool(); };
7 struct Z { int m; operator bool(); };
8
9 template<class T>
10 void f() {
11 int n, m;
12 if (n = m) { } // { dg-warning "parentheses" }
13
14 X x1, x2;
15 if (x1 = x2) { } // { dg-warning "parentheses" }
16
17 Y y1, y2;
18 if (y1 = y2) { } // { dg-warning "parentheses" }
19
20 Z z1, z2;
21 if (z1 = z2) { } // { dg-warning "parentheses" }
22
23 bool b;
24 b = m = n; // { dg-warning "parentheses" }
25 b = x1 = x2; // { dg-warning "parentheses" }
26 b = y1 = y2; // { dg-warning "parentheses" }
27 b = z1 = z2; // { dg-warning "parentheses" }
28 }