* decl.c (make_typename_type): s/parameters/arguments/.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp0x / explicit3.C
blob6318ade2c0e100e516d790926b9ef36f906e7d3d
1 // Test for "contextually converted to bool"
2 // { dg-do compile { target c++11 } }
4 struct A
6   explicit operator bool();
7 };
9 void f (bool);
11 struct B
13   bool b;
16 struct C
18   operator int();
21 struct D
23   operator int();
26 int main()
28   A a; C c; D d;
29   // These contexts use an explicit bool conversion.
30   if (a) {}
31   for (; a; ) {}
32   do {} while (a);
33   while (a) {}
34   a ? 1 : 0;
35   a || true;
36   a && true;
37   !a;
39   a ? c : 1;
40   a ? c : d;
42   // These do not.
43   switch (a);                   // { dg-error "" }
44   bool b = a;                   // { dg-error "" }
45   f(a);                         // { dg-error "" }
46   B b2 = { a };                 // { dg-error "" }
47   a + true;                     // { dg-error "5:no match" }
48   b ? a : true;                 // { dg-error "5:?:" }
49   a ? a : true;                 // { dg-error "5:?:" }