2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / g++.old-deja / g++.law / temps4.C
blob3f8c9ed2c7dea265a695ab10adb68bb1a742afbe
1 // { dg-do run  }
2 // { dg-options "-felide-constructors" }
3 // GROUPS passed temps
4 // temps file
5 // Message-Id: <9311102043.AA22871@ses.com>
6 // From: jamshid@ses.com (Jamshid Afshar)
7 // Subject: elide-constructors (aka return value optimization)
8 // Date: Wed, 10 Nov 93 14:43:54 CST
10 #include <stdio.h>
11 #include <stdlib.h>
13 class X {
14     int i;
15   public:
16     X();
17     X(const X&);
18     X(int);
19     ~X();
22 int did_it = 0;
24 X::X() { ; }
25 X::X(const X&) { did_it = 1; }
26 X::X(int) { ; }
27 X::~X() { ; }
29 X foo() {
30     X x(1);
31     return x;
34 main() {
35     X x = foo();
36     if (did_it)
37         abort ();
38     else
39         printf ("PASS\n");