[committed] analyzer: add regression test for fixed ICE [PR94028]

Message ID 20200304220027.28118-1-dmalcolm@redhat.com
State New
Headers show
Series
  • [committed] analyzer: add regression test for fixed ICE [PR94028]
Related show

Commit Message

David Malcolm March 4, 2020, 10 p.m.
The C++ reproducer for PR analyzer/94028 generates a similar ICE
to that of the Fortran reproducer for PR analyzer/93993 and, like
it, was fixed by r10-7023-g3d66e153b40ed000af30a9e569a05f34d5d576aa.

This patch adds the C++ reproducer as a regression test.

Successfully regrtested on x86_64-pc-linux-gnu.
Pushed to master as 4ac3eb5c5f157bea22b5ae34b0df254d729dac25.

gcc/testsuite/ChangeLog:
	PR analyzer/94028
	* g++.dg/analyzer/pr94028.C: New test.
---
 gcc/testsuite/g++.dg/analyzer/pr94028.C | 36 +++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/analyzer/pr94028.C

-- 
2.21.0

Patch

diff --git a/gcc/testsuite/g++.dg/analyzer/pr94028.C b/gcc/testsuite/g++.dg/analyzer/pr94028.C
new file mode 100644
index 00000000000..0a222d1b991
--- /dev/null
+++ b/gcc/testsuite/g++.dg/analyzer/pr94028.C
@@ -0,0 +1,36 @@ 
+void *calloc (__SIZE_TYPE__, __SIZE_TYPE__);
+
+struct B
+{
+  B (short);
+  int cls;
+} k (0);
+
+void d (int);
+
+enum e {} i;
+
+struct j
+{
+  void *operator new (__SIZE_TYPE__ b)
+  {
+    return calloc (b, sizeof (int)); // { dg-warning "leak" }
+  }
+  j (B *, int)
+  {
+  } // { dg-warning "leak" }
+};
+
+j *
+f (B * b, int h, bool)
+{
+  d (b->cls);
+  return new j (b, h); // { dg-warning "leak" }
+}
+
+void
+m ()
+{
+  if (i)
+    f (&k, 0, false);
+}