[Heikki Kultala] This patch contains the ABI changes for the TCE target.
[clang.git] / test / Analysis / reference.cpp
blob51c8aae66c1ec7f79f7722e6977215bb72382649
1 // RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-store=region -analyzer-constraints=range -verify %s
3 typedef typeof(sizeof(int)) size_t;
4 void malloc (size_t);
6 void f1() {
7 int const &i = 3; // <--- **FIXME** This is currently not being modeled correctly.
8 int b = i;
10 int *p = 0;
12 if (b != 3)
13 *p = 1; // no-warning
16 char* ptr();
17 char& ref();
19 // These next two tests just shouldn't crash.
20 char t1 () {
21 ref() = 'c';
22 return '0';
25 // just a sanity test, the same behavior as t1()
26 char t2 () {
27 *ptr() = 'c';
28 return '0';
31 // Each of the tests below is repeated with pointers as well as references.
32 // This is mostly a sanity check, but then again, both should work!
33 char t3 () {
34 char& r = ref();
35 r = 'c'; // no-warning
36 if (r) return r;
37 return *(char*)0; // no-warning
40 char t4 () {
41 char* p = ptr();
42 *p = 'c'; // no-warning
43 if (*p) return *p;
44 return *(char*)0; // no-warning
47 char t5 (char& r) {
48 r = 'c'; // no-warning
49 if (r) return r;
50 return *(char*)0; // no-warning
53 char t6 (char* p) {
54 *p = 'c'; // no-warning
55 if (*p) return *p;
56 return *(char*)0; // no-warning