blob: 9951943e30604867ff4c71e214055c9a0fd645b6 [file] [log] [blame]
Dominic Chen184c6242017-03-03 18:02:02 +00001// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection %s -verify
Jordan Rose1bbd1432012-10-23 23:59:08 +00002
Jordan Rose62ac9ec2014-04-29 17:08:12 +00003void clang_analyzer_checkInlined(bool);
Jordan Rose1bbd1432012-10-23 23:59:08 +00004void clang_analyzer_eval(int);
5
6namespace 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 Rose62ac9ec2014-04-29 17:08:12 +000024}
25
26namespace 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}