https://github.com/hongtaihu created 
https://github.com/llvm/llvm-project/pull/241705

`Analysis/redecl.c` already produces the expected `TRUE` result, but its 
`-verify` run fails on an unannotated `'extern' variable has an initializer` 
warning. Add the missing `expected-warning` and remove `XFAIL: *`, retaining 
the original input and the existing `TRUE` check.

The test was added by 850361f6c1db6bd8a85b65a8c56e0e097eaa0635 (D46421, April 
23, 2019), which also changed the constant-variable lookup in 
`RegionStoreManager::getBindingForVar` from `getInit()` to 
`getAnyInitializer()`. Native X86 Release builds with assertions enabled 
confirm the behavior change at that commit: its parent 
330bc8af131c5b42efe120dbf70f47881d02d3a3 reports both `FALSE` and `TRUE`, while 
the commit reports only `TRUE`. Both still emit the extern-initializer warning, 
so the original test remains XFAIL even after the analysis result is corrected.

Validation:

- On both exact revisions, run the original analysis, original `-verify`, and 
the test with the added warning expectation, twice each. The annotated test 
fails on the parent because of the unexpected `FALSE` and passes on 
850361f6c1db on both attempts.
- The complete updated test also passes its original analyzer RUN command twice 
on the assertions-enabled build at 90fd89ca9155697a1fa4dc2285a4876a8db5ad20.

Prepared with assistance from Codex.


>From d732fc1c8799400ffe7ff49675ad288613fde33d Mon Sep 17 00:00:00 2001
From: Macro Terra <[email protected]>
Date: Thu, 12 Nov 2026 14:16:09 +0800
Subject: [PATCH] [Clang][analyzer][NFC] Re-enable const variable redeclaration
 test

Annotate the existing extern-initializer warning and remove XFAIL,
keeping the original input and analyzer TRUE expectation unchanged.
Native assertions builds confirm the analysis result was corrected by
850361f6c1db, the same commit that introduced this test.

Prepared with assistance from Codex.
---
 clang/test/Analysis/redecl.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/test/Analysis/redecl.c b/clang/test/Analysis/redecl.c
index f5771a731779c5..307fdeaccbcb03 100644
--- a/clang/test/Analysis/redecl.c
+++ b/clang/test/Analysis/redecl.c
@@ -1,5 +1,4 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify 
%s
-// XFAIL: *
 
 void clang_analyzer_eval(int);
 
@@ -10,4 +9,4 @@ int main()
     clang_analyzer_eval(extInt == 2); // expected-warning{{TRUE}}
 }
 
-extern const int extInt = 2;
+extern const int extInt = 2; // expected-warning{{'extern' variable has an 
initializer}}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to