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

via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 2 09:11:31 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Ella Ma (Snape3058)

<details>
<summary>Changes</summary>

Following PR #<!-- -->70792 for issue #<!-- -->70464 
Add a test case for issue #<!-- -->59493 

---
Full diff: https://github.com/llvm/llvm-project/pull/71073.diff


1 Files Affected:

- (modified) clang/test/Analysis/issue-70464.cpp (+20) 


``````````diff
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

``````````

</details>


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


More information about the cfe-commits mailing list