Daniel Dunbar | d7d5f02 | 2009-03-24 02:24:46 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
Anders Carlsson | b88d45e | 2008-08-23 21:12:35 +0000 | [diff] [blame] | 2 | |
| 3 | // Bool literals can be enum values. |
| 4 | enum { |
| 5 | ReadWrite = false, |
| 6 | ReadOnly = true |
| 7 | }; |
Sebastian Redl | e6d5a4a | 2008-12-20 09:35:34 +0000 | [diff] [blame] | 8 | |
| 9 | // bool cannot be decremented, and gives a warning on increment |
| 10 | void test(bool b) |
| 11 | { |
| 12 | ++b; // expected-warning {{incrementing expression of type bool is deprecated}} |
| 13 | b++; // expected-warning {{incrementing expression of type bool is deprecated}} |
| 14 | --b; // expected-error {{cannot decrement expression of type bool}} |
| 15 | b--; // expected-error {{cannot decrement expression of type bool}} |
Douglas Gregor | d249e1d1f | 2009-05-29 20:38:28 +0000 | [diff] [blame] | 16 | |
| 17 | bool *b1 = (int *)0; // expected-error{{expected 'bool *'}} |
Sebastian Redl | e6d5a4a | 2008-12-20 09:35:34 +0000 | [diff] [blame] | 18 | } |