Jordan Rose | a5796f8 | 2013-04-09 02:30:33 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=debug.ExprInspection %s |
| 2 | |
| 3 | void clang_analyzer_eval(bool); |
| 4 | |
| 5 | enum class Foo { |
| 6 | Zero |
| 7 | }; |
| 8 | |
| 9 | bool pr15703(int x) { |
| 10 | return Foo::Zero == (Foo)x; // don't crash |
| 11 | } |
| 12 | |
| 13 | void testCasting(int i) { |
| 14 | Foo f = static_cast<Foo>(i); |
| 15 | int j = static_cast<int>(f); |
| 16 | if (i == 0) |
| 17 | { |
| 18 | clang_analyzer_eval(f == Foo::Zero); // expected-warning{{TRUE}} |
| 19 | clang_analyzer_eval(j == 0); // expected-warning{{TRUE}} |
| 20 | } |
| 21 | else |
| 22 | { |
| 23 | clang_analyzer_eval(f == Foo::Zero); // expected-warning{{FALSE}} |
| 24 | clang_analyzer_eval(j == 0); // expected-warning{{FALSE}} |
| 25 | } |
| 26 | } |