| 1 |
// { dg-do run } |
| 2 |
// { dg-options "-felide-constructors" } |
| 3 |
// GROUPS passed temps |
| 4 |
// temps file |
| 5 |
// Message-Id: <[email protected]> |
| 6 |
// From: [email protected] (Jamshid Afshar) |
| 7 |
// Subject: elide-constructors (aka return value optimization) |
| 8 |
// Date: Wed, 10 Nov 93 14:43:54 CST |
| 9 |
|
| 10 |
#include <stdio.h> |
| 11 |
#include <stdlib.h> |
| 12 |
|
| 13 |
class X { |
| 14 |
int i; |
| 15 |
public: |
| 16 |
X(); |
| 17 |
X(const X&); |
| 18 |
X(int); |
| 19 |
~X(); |
| 20 |
}; |
| 21 |
|
| 22 |
int did_it = 0; |
| 23 |
|
| 24 |
X::X() { ; } |
| 25 |
X::X(const X&) { did_it = 1; } |
| 26 |
X::X(int) { ; } |
| 27 |
X::~X() { ; } |
| 28 |
|
| 29 |
X foo() { |
| 30 |
X x(1); |
| 31 |
return x; |
| 32 |
} |
| 33 |
|
| 34 |
int |
| 35 |
main() { |
| 36 |
X x = foo(); |
| 37 |
if (did_it) |
| 38 |
abort (); |
| 39 |
else |
| 40 |
printf ("PASS\n"); |
| 41 |
|
| 42 |
return 0; |
| 43 |
} |