1 // RUN: %clang_cc1 -fsyntax-only -Wuninitialized-const-reference -verify %s 2 3 class A { 4 public: 5 int i; 6 A(){}; 7 A(const A &a){}; 8 A(int i) {} 9 bool operator!=(const A &); 10 }; 11 12 A const_ref_use_A(const A &a); 13 int const_ref_use(const int &i); 14 A const_use_A(const A a); 15 int const_use(const int i); 16 17 void f(int a) { 18 int i; 19 const_ref_use(i); // expected-warning {{variable 'i' is uninitialized when passed as a const reference argument here}} 20 int j = j + const_ref_use(j); // expected-warning {{variable 'j' is uninitialized when used within its own initialization}} expected-warning {{variable 'j' is uninitialized when passed as a const reference argument here}} 21 A a1 = const_ref_use_A(a1); // expected-warning {{variable 'a1' is uninitialized when passed as a const reference argument here}} 22 int k = const_use(k); // expected-warning {{variable 'k' is uninitialized when used within its own initialization}} 23 A a2 = const_use_A(a2); // expected-warning {{variable 'a2' is uninitialized when used within its own initialization}} 24 A a3(const_ref_use_A(a3)); // expected-warning {{variable 'a3' is uninitialized when passed as a const reference argument here}} 25 A a4 = a3 != a4; // expected-warning {{variable 'a4' is uninitialized when used within its own initialization}} expected-warning {{variable 'a4' is uninitialized when passed as a const reference argument here}} 26 int n = n; // expected-warning {{variable 'n' is uninitialized when used within its own initialization}} 27 const_ref_use(n); 28 29 A a5; 30 const_ref_use_A(a5); 31 32 int m; 33 if (a < 42) 34 m = 1; 35 const_ref_use(m); 36 } 37