Debian Codegraph @

gcc/testsuite/g++.old-deja/g++.jason/bool.C

raw
1 // { dg-do assemble }
2 // Testcase for uses of bool.
3
4 int i,j,k;
5
6 /* Check that types of certain expressions are bool. */
7 void f ()
8 {
9 i ? j == k : true;
10 i ? j < k : true;
11 i ? j && k : true;
12 }
13
14 /* Check that g++ can find a conversion to bool when one exists. */
15 struct A { operator char * (); } a;
16 struct B { operator int (); } b;
17 struct C { operator float (); } c;
18 struct D { operator bool (); } d;
19 struct E { operator int E::* (); } e;
20
21 void g ()
22 {
23 a || true;
24 b || true;
25 c || true; // { dg-bogus "" }
26 d || true;
27 e || true;
28 }
29
30 /* Check for support in templates. */
31 template <class T> struct F { };
32 template class F<bool>;
33
34 template <class T> void f (T, bool) { }
35 template void f (bool, bool);
36
37 /* Special cases. */
38 void h ()
39 {
40 /* Used to cause infinite recursion. */
41 i&1 || true;
42 /* Should find conversion path to int. */
43 d == true;
44 }
45
46 bool boo = -1;