blob: 17fc74d06f4611023f54a772b788b4120b1ccdb1 [file] [log] [blame]
Argyrios Kyrtzidisc4d2c902011-02-28 19:49:42 +00001// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
Argyrios Kyrtzidisf4699d12011-02-18 20:55:19 +00002
3int f1(char *dst) {
4 char *p = dst + 4;
5 char *q = dst + 3;
6 return !(q >= p);
7}
Argyrios Kyrtzidis4f20de12011-02-18 21:24:56 +00008
Argyrios Kyrtzidis7ff07dc2011-02-19 01:08:41 +00009long f2(char *c) {
10 return long(c) & 1;
11}
12
Argyrios Kyrtzidis370e6e92011-02-19 01:59:41 +000013bool f3() {
14 return !false;
15}
16
Argyrios Kyrtzidisb14175a2011-02-19 08:03:18 +000017void *f4(int* w) {
18 return reinterpret_cast<void*&>(w);
19}
20
Argyrios Kyrtzidis4f20de12011-02-18 21:24:56 +000021namespace {
22
23struct A { };
24struct B {
John McCall15e310a2011-02-19 02:53:41 +000025 operator A() { return A(); }
Argyrios Kyrtzidis4f20de12011-02-18 21:24:56 +000026};
27
28A f(char *dst) {
29 B b;
30 return b;
31}
32
33}
Argyrios Kyrtzidisb14175a2011-02-19 08:03:18 +000034
35namespace {
36
37struct S {
38 void *p;
39};
40
41void *f(S* w) {
42 return &reinterpret_cast<void*&>(*w);
43}
44
45}
Anders Carlsson65b427f2011-03-26 14:30:44 +000046
47namespace {
48
49struct C {
50 void *p;
51 static void f();
52};
53
54void C::f() { }
55
56}