]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: add testcase verifying non-dep new-expr checking
authorPatrick Palka <ppalka@redhat.com>
Fri, 27 Oct 2023 15:26:40 +0000 (11:26 -0400)
committerPatrick Palka <ppalka@redhat.com>
Fri, 27 Oct 2023 15:26:40 +0000 (11:26 -0400)
gcc/testsuite/ChangeLog:

* g++.dg/template/new14.C: New test.

gcc/testsuite/g++.dg/template/new14.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/template/new14.C b/gcc/testsuite/g++.dg/template/new14.C
new file mode 100644 (file)
index 0000000..8c0efe4
--- /dev/null
@@ -0,0 +1,20 @@
+// Verify we check new-expressions ahead of time.
+
+struct A { };
+struct B { B(int); };
+struct C { void* operator new(__SIZE_TYPE__, int); };
+
+template<class T>
+void f() {
+  new A(1); // { dg-error "no match" "" { xfail *-*-* } }
+  new B(1, 2); // { dg-error "no match" }
+  new B; // { dg-error "no match" }
+  new C; // { dg-error "no match" }
+}
+
+
+template<class T>
+void g() {
+  new int[__SIZE_MAX__]; // { dg-error "exceeds maximum" }
+  new int[__SIZE_MAX__ / sizeof(int)]; // { dg-error "exceeds maximum" }
+}