[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Sema / warn-uninitialized-statement-expression.c
blob4e29ee01eab931635fed86b2d121eaffb8034317
1 // RUN: %clang_cc1 -fsyntax-only -Wuninitialized -verify %s
3 void init(int *);
5 void foo(void) {
6 int i = ({
7 init(&i);
8 i;
9 });
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);
17 });
20 struct widget {
21 int x, y;
23 void init2(struct widget *);
25 void bar(void) {
26 struct widget my_widget = ({
27 init2(&my_widget);
28 my_widget;
29 });
30 struct widget a = (init2(&a), a);
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 });
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 });
48 });
51 void f(void) {
52 struct widget *a = ({
53 init2(a); // expected-warning{{variable 'a' is uninitialized when used within its own initialization}}
55 });