[clang] [clang] Combine ConstRefUse with other warnings for uninitialized values (PR #147898)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 10 11:02:34 PDT 2025


================
@@ -27,7 +27,7 @@ int const_use(const int i);
 void f(int a) {
   int i;
   const_ref_use(i);             // expected-warning {{variable 'i' is uninitialized when passed as a const reference argument here}}
-  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}}
+  int j = j + const_ref_use(j); // expected-warning {{variable 'j' is uninitialized when used within its own initialization}}
----------------
zygoloid wrote:

It'd be nice to also have a non-self-init test where the same variable has both a const ref use and other kinds of use, to make sure we properly prioritize the diagnostics.

https://github.com/llvm/llvm-project/pull/147898


More information about the cfe-commits mailing list