aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.law/temps4.C
blob: 2abf56d8214caf39b517145a4b3131f342079408 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Special g++ Options: -felide-constructors
// GROUPS passed temps
// temps file
// Message-Id: <9311102043.AA22871@ses.com>
// From: jamshid@ses.com (Jamshid Afshar)
// Subject: elide-constructors (aka return value optimization)
// Date: Wed, 10 Nov 93 14:43:54 CST

#include <stdio.h>

class X {
    int i;
  public:
    X();
    X(const X&);
    X(int);
    ~X();
};

int did_it = 0;

X::X() { ; }
X::X(const X&) { did_it = 1; }
X::X(int) { ; }
X::~X() { ; }

X foo() {
    X x(1);
    return x;
}

main() {
    X x = foo();
    if (did_it)
	printf ("FAIL\n");
    else
	printf ("PASS\n");
}