Jordan Rose | 1bbd143 | 2012-10-23 23:59:08 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection %s -verify |
| 2 | |
Jordan Rose | 62ac9ec | 2014-04-29 17:08:12 +0000 | [diff] [blame] | 3 | void clang_analyzer_checkInlined(bool); |
Jordan Rose | 1bbd143 | 2012-10-23 23:59:08 +0000 | [diff] [blame] | 4 | void clang_analyzer_eval(int); |
| 5 | |
| 6 | namespace EnumsViaMemberExpr { |
| 7 | struct Foo { |
| 8 | enum E { |
| 9 | Bar = 1 |
| 10 | }; |
| 11 | }; |
| 12 | |
| 13 | void testEnumVal(Foo Baz) { |
| 14 | clang_analyzer_eval(Baz.Bar == Foo::Bar); // expected-warning{{TRUE}} |
| 15 | } |
| 16 | |
| 17 | void testEnumRef(Foo &Baz) { |
| 18 | clang_analyzer_eval(Baz.Bar == Foo::Bar); // expected-warning{{TRUE}} |
| 19 | } |
| 20 | |
| 21 | void testEnumPtr(Foo *Baz) { |
| 22 | clang_analyzer_eval(Baz->Bar == Foo::Bar); // expected-warning{{TRUE}} |
| 23 | } |
Jordan Rose | 62ac9ec | 2014-04-29 17:08:12 +0000 | [diff] [blame] | 24 | } |
| 25 | |
| 26 | namespace PR19531 { |
| 27 | struct A { |
| 28 | A() : x(0) {} |
| 29 | bool h() const; |
| 30 | int x; |
| 31 | }; |
| 32 | |
| 33 | struct B { |
| 34 | void g(bool (A::*mp_f)() const) { |
| 35 | // This used to trigger an assertion because the 'this' pointer is a |
| 36 | // temporary. |
| 37 | (A().*mp_f)(); |
| 38 | } |
| 39 | void f() { g(&A::h); } |
| 40 | }; |
| 41 | } |