[clang] [clang][analyzer] Add a test case to PR-70792 for Issue-59493 (PR #71073)

Ella Ma via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 2 09:10:54 PDT 2023


https://github.com/Snape3058 created https://github.com/llvm/llvm-project/pull/71073

Following PR #70792 for issue #70464 
Add a test case for issue #59493 

>From 90d72a1f1036d2486e66c5ec16c3a8dc4241fc00 Mon Sep 17 00:00:00 2001
From: Ella Ma <alansnape3058 at gmail.com>
Date: Thu, 2 Nov 2023 23:14:15 +0800
Subject: [PATCH] [clang][analyzer] Add a test case to PR-70792 for Issue-59493

---
 clang/test/Analysis/issue-70464.cpp | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/clang/test/Analysis/issue-70464.cpp b/clang/test/Analysis/issue-70464.cpp
index f3b3072eb919823..331068775821e7e 100644
--- a/clang/test/Analysis/issue-70464.cpp
+++ b/clang/test/Analysis/issue-70464.cpp
@@ -66,3 +66,23 @@ struct Derived : Base {
 void entry() { Derived test; }
 
 } // namespace delegate_ctor_call
+
+// Additional test case from issue #59493
+namespace init_list_array {
+
+struct Base {
+  int foox[1];
+};
+
+class Derived : public Base {
+public:
+  Derived() : Base{{42}} {
+    // The dereference to this->foox below should be initialized properly.
+    clang_analyzer_dump(this->foox[0]); // expected-warning{{42 S32b}}
+    clang_analyzer_dump(foox[0]); // expected-warning{{42 S32b}}
+  }
+};
+
+void entry() { Derived test; }
+
+} // namespace init_list_array



More information about the cfe-commits mailing list