xref: /openbsd-src/gnu/usr.bin/gcc/gcc/testsuite/g++.old-deja/g++.jason/bool.C (revision c87b03e512fc05ed6e0222f6fb0ae86264b1d05b)
1 // Testcase for uses of bool.
2 // Build don't link:
3 
4 int i,j,k;
5 
6 /* Check that types of certain expressions are bool.  */
f()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 
g()21 void g ()
22 {
23   a || true;
24   b || true;
25   c || true;			// gets bogus error
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 
f(T,bool)34 template <class T> void f (T, bool) { };
35 template void f (bool, bool);
36 
37 /* Special cases.  */
h()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;
47