From: David Malcolm Date: Fri, 25 Sep 2020 18:31:46 +0000 (-0400) Subject: analyzer: add test for placement new X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d4a906e7b51f3fc31f3328810f45ae4cf2e7bbc3;p=gcc.git analyzer: add test for placement new gcc/testsuite/ChangeLog: PR analyzer/94355 * g++.dg/analyzer/placement-new.C: New test. --- diff --git a/gcc/testsuite/g++.dg/analyzer/placement-new.C b/gcc/testsuite/g++.dg/analyzer/placement-new.C new file mode 100644 index 00000000000..8250f45b9d9 --- /dev/null +++ b/gcc/testsuite/g++.dg/analyzer/placement-new.C @@ -0,0 +1,26 @@ +#include + +/* Placement new. */ + +void test_1 (void) +{ + char buf[sizeof(int)]; + int *p = new(buf) int (42); +} + +/* Placement new[]. */ + +void test_2 (void) +{ + char buf[sizeof(int) * 10]; + int *p = new(buf) int[10]; +} + +/* Delete of placement new. */ + +void test_3 (void) +{ + char buf[sizeof(int)]; + int *p = new(buf) int (42); + delete p; // { dg-warning "memory not on the heap" } +}