57 lines · c
1// RUN: %clang_cc1 -fsyntax-only -Wuninitialized -verify %s2 3void init(int *);4 5void foo(void) {6 int i = ({7 init(&i);8 i;9 });10}11 12void 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 20struct widget {21 int x, y;22};23void init2(struct widget *);24 25void bar(void) {26 struct widget my_widget = ({27 init2(&my_widget);28 my_widget;29 });30 struct widget a = (init2(&a), a);31}32 33void 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 here37 init2(&my_widget);38 my_widget;39 });40}41 42void 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 51void 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}57