OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [g++.old-deja/] [g++.law/] [temps2.C] - Blame information for rev 823

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
// { dg-do run  }
2
// GROUPS passed temps
3
// temps file
4
// Message-Id: <9212181914.AA05066@sparc1.cnm.us.es>
5
// From: juando@cnm.us.es (Juan Domingo Martin Gomez)
6
// Subject: Temporaries destroyed too soon
7
// Date: Fri, 18 Dec 92 20:14:45 +0100
8
 
9
#include 
10
 
11
int status = 0;
12
int fail = 0;
13
 
14
class Foo
15
{
16
public:
17
    Foo();
18
    ~Foo();
19
 
20
    Foo &method();
21
};
22
 
23
Foo f1()
24
{
25
    return Foo();
26
}
27
 
28
Foo::Foo()
29
{
30
}
31
 
32
Foo::~Foo()
33
{
34
    if (status == 2)
35
      fail = 0;
36
    else
37
      fail = 1;
38
}
39
 
40
Foo &Foo::method()
41
{
42
    status++;
43
    return *this;
44
}
45
 
46
int main()
47
{
48
    // f1() returns a temporary object. The member function
49
    // method() returns a reference to the same object.
50
    f1().method().method();
51
    if (fail)
52
      { printf ("FAIL\n"); return 1; }
53
    else
54
      printf ("PASS\n");
55
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.