blob: 12e8bbf3671c1e9639fb49056f22b0aff91d9130 [file] [log] [blame]
Jordan Rosef1e67d72012-10-17 19:35:37 +00001// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection %s -analyzer-store=region -verify
2
3void clang_analyzer_eval(int);
Ted Kremenek5c456fe2008-10-18 03:28:48 +00004
5unsigned foo();
6typedef struct bf { unsigned x:2; } bf;
7void bar() {
8 bf y;
9 *(unsigned*)&y = foo();
10 y.x = 1;
11}
Zhongxing Xu5414a5c2009-06-21 13:24:24 +000012
13struct s {
14 int n;
15};
16
17void f() {
18 struct s a;
19 int *p = &(a.n) + 1;
20}
Argyrios Kyrtzidisc2e20d02011-02-03 22:01:32 +000021
22typedef struct {
23 int x,y;
24} Point;
25
26Point getit(void);
27void test() {
28 Point p;
29 (void)(p = getit()).x;
30}
Jordan Rosef1e67d72012-10-17 19:35:37 +000031
32
33void testLazyCompoundVal() {
34 Point p = {42, 0};
35 Point q;
36 clang_analyzer_eval((q = p).x == 42); // expected-warning{{TRUE}}
37 clang_analyzer_eval(q.x == 42); // expected-warning{{TRUE}}
38}