1 // RUN: %clang_cc1 -fsyntax-only -fcxx-exceptions -fexceptions -Wuninitialized-const-reference -verify %s
9 bool operator!=(const A
&);
13 void ignore_template(const T
&) {}
14 void ignore(const int &i
) {}
15 void dont_ignore_non_empty(const int &i
) { ; } // Calling this won't silence the warning for you
16 void dont_ignore_block(const int &i
) {
18 } // Calling this won't silence the warning for you
19 void ignore_function_try_block_maybe_who_knows(const int &) try {
22 A
const_ref_use_A(const A
&a
);
23 int const_ref_use(const int &i
);
24 A
const_use_A(const A a
);
25 int const_use(const int i
);
29 const_ref_use(i
); // expected-warning {{variable 'i' is uninitialized when passed as a const reference argument here}}
30 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}}
31 A a1
= const_ref_use_A(a1
); // expected-warning {{variable 'a1' is uninitialized when passed as a const reference argument here}}
32 int k
= const_use(k
); // expected-warning {{variable 'k' is uninitialized when used within its own initialization}}
33 A a2
= const_use_A(a2
); // expected-warning {{variable 'a2' is uninitialized when used within its own initialization}}
34 A
a3(const_ref_use_A(a3
)); // expected-warning {{variable 'a3' is uninitialized when passed as a const reference argument here}}
35 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}}
36 int n
= n
; // expected-warning {{variable 'n' is uninitialized when used within its own initialization}}
48 ignore_template(l
); // This is a pattern to avoid "unused variable" warnings (e.g. boost::ignore_unused).
50 dont_ignore_non_empty(l
); // expected-warning {{variable 'l' is uninitialized when passed as a const reference argument here}}
52 dont_ignore_block(l1
); // expected-warning {{variable 'l1' is uninitialized when passed as a const reference argument here}}
54 ignore_function_try_block_maybe_who_knows(l2
); // expected-warning {{variable 'l2' is uninitialized when passed as a const reference argument here}}