From ed23fa65c1d565ca2055de9d2ba29748b4b5102d Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Fri, 12 Sep 2025 16:12:11 -0400
Subject: [PATCH 71/98] FIXME: unfinished WIP on std:: test coverage

---
 gcc/testsuite/g++.dg/analyzer/std-deque-1.C   | 15 ++++++++++++
 .../g++.dg/analyzer/std-forward_list-1.C      | 15 ++++++++++++
 gcc/testsuite/g++.dg/analyzer/std-list-1.C    | 15 ++++++++++++
 gcc/testsuite/g++.dg/analyzer/std-set-1.C     | 15 ++++++++++++
 gcc/testsuite/g++.dg/analyzer/std-string-1.C  | 23 +++++++++++++++++++
 gcc/testsuite/g++.dg/analyzer/std-vector-1.C  | 17 ++++++++++++++
 gcc/testsuite/g++.dg/analyzer/std-vector-2.C  | 18 +++++++++++++++
 7 files changed, 118 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/analyzer/std-deque-1.C
 create mode 100644 gcc/testsuite/g++.dg/analyzer/std-forward_list-1.C
 create mode 100644 gcc/testsuite/g++.dg/analyzer/std-list-1.C
 create mode 100644 gcc/testsuite/g++.dg/analyzer/std-set-1.C
 create mode 100644 gcc/testsuite/g++.dg/analyzer/std-string-1.C
 create mode 100644 gcc/testsuite/g++.dg/analyzer/std-vector-1.C
 create mode 100644 gcc/testsuite/g++.dg/analyzer/std-vector-2.C

diff --git a/gcc/testsuite/g++.dg/analyzer/std-deque-1.C b/gcc/testsuite/g++.dg/analyzer/std-deque-1.C
new file mode 100644
index 000000000000..2e9b24b5fa91
--- /dev/null
+++ b/gcc/testsuite/g++.dg/analyzer/std-deque-1.C
@@ -0,0 +1,15 @@
+#include <deque>
+
+void
+test_empty ()
+{
+  std::deque<int> d;
+}
+
+std::deque<int>
+test_copy (std::deque<int> d)
+{
+  return d;
+}
+
+// FIXME: the header is giving: warning: use of uninitialized value ‘*__new_node’ [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
diff --git a/gcc/testsuite/g++.dg/analyzer/std-forward_list-1.C b/gcc/testsuite/g++.dg/analyzer/std-forward_list-1.C
new file mode 100644
index 000000000000..94fd8b5f94fe
--- /dev/null
+++ b/gcc/testsuite/g++.dg/analyzer/std-forward_list-1.C
@@ -0,0 +1,15 @@
+#include <forward_list>
+
+void
+test_empty ()
+{
+  std::forward_list<int> c;
+}
+
+std::forward_list<int>
+test_copy (std::forward_list<int> c)
+{
+  return c;
+}
+
+// FIXME: untested
diff --git a/gcc/testsuite/g++.dg/analyzer/std-list-1.C b/gcc/testsuite/g++.dg/analyzer/std-list-1.C
new file mode 100644
index 000000000000..05af2e0f8e35
--- /dev/null
+++ b/gcc/testsuite/g++.dg/analyzer/std-list-1.C
@@ -0,0 +1,15 @@
+#include <list>
+
+void
+test_empty ()
+{
+  std::list<int> c;
+}
+
+std::list<int>
+test_copy (std::list<int> c)
+{
+  return c;
+}
+
+// FIXME: untested
diff --git a/gcc/testsuite/g++.dg/analyzer/std-set-1.C b/gcc/testsuite/g++.dg/analyzer/std-set-1.C
new file mode 100644
index 000000000000..1e3395dcc0df
--- /dev/null
+++ b/gcc/testsuite/g++.dg/analyzer/std-set-1.C
@@ -0,0 +1,15 @@
+#include <set>
+
+void
+test_empty ()
+{
+  std::set<int> c;
+}
+
+std::set<int>
+test_copy (std::set<int> c)
+{
+  return c;
+}
+
+// FIXME: untested
diff --git a/gcc/testsuite/g++.dg/analyzer/std-string-1.C b/gcc/testsuite/g++.dg/analyzer/std-string-1.C
new file mode 100644
index 000000000000..2db8a1b37c5b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/analyzer/std-string-1.C
@@ -0,0 +1,23 @@
+#include "../../gcc.dg/analyzer/analyzer-decls.h"
+
+#include <string>
+
+void
+test_empty ()
+{
+  // FIXME: this is currently giving: warning: 'delete' of '__p' which points to memory on the stack [CWE-590] [-Wanalyzer-free-of-non-heap]
+  std::string s;
+}
+
+std::string
+test_copy (std::string s)
+{
+  return s;
+}
+
+void
+test_c_str (std::string s)
+{
+  // FIXME: this is currently returning UNKNOWN:
+  __analyzer_eval (s.c_str () != (void *)0); // { dg-warning "TRUE" }
+}
diff --git a/gcc/testsuite/g++.dg/analyzer/std-vector-1.C b/gcc/testsuite/g++.dg/analyzer/std-vector-1.C
new file mode 100644
index 000000000000..6bdc69676d9b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/analyzer/std-vector-1.C
@@ -0,0 +1,17 @@
+#include "../../gcc.dg/analyzer/analyzer-decls.h"
+
+#include <vector>
+
+void
+test_empty ()
+{
+  std::vector<int> v;
+}
+
+std::vector<int>
+test_copy (std::vector<int> v)
+{
+  return v;
+}
+
+// FIXME: this is currently bailing out with "too-complex"
diff --git a/gcc/testsuite/g++.dg/analyzer/std-vector-2.C b/gcc/testsuite/g++.dg/analyzer/std-vector-2.C
new file mode 100644
index 000000000000..9a98b2786fe4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/analyzer/std-vector-2.C
@@ -0,0 +1,18 @@
+#include "../../gcc.dg/analyzer/analyzer-decls.h"
+
+#include <vector>
+
+int
+test_invalid_iter ()
+{
+  std::vector<int> v;
+  v.push_back (42);
+
+  int &ir = v[0];
+
+  v.push_back (1066); // FIXME: this could invalidate the reference above
+
+  return ir;
+}
+
+// FIXME: bailing out with "too complex"
-- 
2.49.0

