150
|
1 // RUN: %clang_cc1 -fsyntax-only -Wuninitialized -verify %s
|
|
2
|
|
3 void init(int *);
|
|
4
|
|
5 void foo(void) {
|
|
6 int i = ({
|
|
7 init(&i);
|
|
8 i;
|
|
9 });
|
|
10 }
|
|
11
|
|
12 void foo_bad(void) {
|
|
13 int i = ({
|
|
14 int z = i; // expected-warning{{variable 'i' is uninitialized when used within its own initialization}}
|
|
15 init(&i);
|
|
16 i;
|
|
17 });
|
|
18 }
|
|
19
|
|
20 struct widget {
|
|
21 int x, y;
|
|
22 };
|
|
23 void init2(struct widget *);
|
|
24
|
|
25 void bar(void) {
|
|
26 struct widget my_widget = ({
|
|
27 init2(&my_widget);
|
|
28 my_widget;
|
|
29 });
|
|
30 struct widget a = (init2(&a), a);
|
|
31 }
|
|
32
|
|
33 void bar_bad(void) {
|
|
34 struct widget my_widget = ({
|
|
35 struct widget z = my_widget; // expected-warning{{variable 'my_widget' is uninitialized when used within its own initialization}}
|
|
36 int x = my_widget.x; //FIXME: There should be an uninitialized warning here
|
|
37 init2(&my_widget);
|
|
38 my_widget;
|
|
39 });
|
|
40 }
|
|
41
|
|
42 void baz(void) {
|
|
43 struct widget a = ({
|
|
44 struct widget b = ({
|
|
45 b = a; // expected-warning{{variable 'a' is uninitialized when used within its own initialization}}
|
|
46 });
|
|
47 a;
|
|
48 });
|
|
49 }
|
|
50
|
|
51 void f(void) {
|
|
52 struct widget *a = ({
|
|
53 init2(a); // expected-warning{{variable 'a' is uninitialized when used within its own initialization}}
|
|
54 a;
|
|
55 });
|
|
56 }
|