* [pushed] c++: add testcase verifying non-dep new-expr checking
@ 2023-10-27 15:26 Patrick Palka
0 siblings, 0 replies; only message in thread
From: Patrick Palka @ 2023-10-27 15:26 UTC (permalink / raw)
To: gcc-patches; +Cc: jason, Patrick Palka
N.B. we currently don't diagnose 'new A(1)' below ultimately because
when in a template context our valid ctor call checking only happens for
type_build_ctor_call types.
-- >8 --
gcc/testsuite/ChangeLog:
* g++.dg/template/new14.C: New test.
---
gcc/testsuite/g++.dg/template/new14.C | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
create mode 100644 gcc/testsuite/g++.dg/template/new14.C
diff --git a/gcc/testsuite/g++.dg/template/new14.C b/gcc/testsuite/g++.dg/template/new14.C
new file mode 100644
index 00000000000..8c0efe47ae2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/new14.C
@@ -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" }
+}
--
2.42.0.482.g2e8e77cbac
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-10-27 15:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-27 15:26 [pushed] c++: add testcase verifying non-dep new-expr checking Patrick Palka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).