xref: /minix3/external/bsd/llvm/dist/clang/test/Analysis/member-expr.cpp (revision bdb565187c0f1a04513dd488df843317b27f86c8)
1 // RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection %s -verify
2 
3 void clang_analyzer_checkInlined(bool);
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   }
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 }
42