From eb52a1638d528ce0c8df43d1a870da1474c2428f Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 17 Jun 2004 23:05:15 -0400 Subject: [PATCH] new test From-SVN: r83337 --- gcc/testsuite/g++.dg/ext/stmtexpr2.C | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 gcc/testsuite/g++.dg/ext/stmtexpr2.C diff --git a/gcc/testsuite/g++.dg/ext/stmtexpr2.C b/gcc/testsuite/g++.dg/ext/stmtexpr2.C new file mode 100644 index 00000000000..7294577348f --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/stmtexpr2.C @@ -0,0 +1,39 @@ +// { dg-do run } +// { dg-options "" } + +extern "C" int printf (char const *, ...); +extern "C" void abort (); + +static unsigned int expected[] = { + 11, 10, 21, 110, 111, 121 +}; +static unsigned int pointer = 0; + +static void Check (unsigned t, unsigned i, void const *ptr, char const *name) +{ + printf ("%d %d %p %s\n", t, i, ptr, name); + + if (pointer > sizeof(expected)/sizeof(expected[0])) + abort (); + if (t + i != expected[pointer++]) + abort (); +} + +struct A +{ + int I; + + A (int i) : I(i) { Check (0, I, this, __PRETTY_FUNCTION__); } + ~A () { Check (100, I, this, __PRETTY_FUNCTION__); } + A (A const &a) : I(a.I) { Check (200, I, this, __PRETTY_FUNCTION__); } + A &operator= (A const &a) + { I = a.I; Check (300, I, this, __PRETTY_FUNCTION__); return *this; } + void Foo () const { Check (400, I, this, __PRETTY_FUNCTION__); } + A operator+ (A const &a) const + { return A(I + a.I); } +}; + +int main () +{ + ({ A(10) + A(11); }); +} -- 2.30.2