From: Jason Merrill Date: Fri, 18 Jun 2004 03:05:15 +0000 (-0400) Subject: new test X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=eb52a1638d528ce0c8df43d1a870da1474c2428f;p=gcc.git new test From-SVN: r83337 --- 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); }); +}