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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.old-deja/] [g++.brendan/] [reference1.C] - Blame information for rev 699

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 699 jeremybenn
// { dg-do run  }
2
// { dg-options "-w" }
3
// GROUPS passed references
4
// Check that if a reference is initialized to refer to a value
5
// which is returned from a function call, the actual call to
6
// the function is only invoked for the original initialization
7
// of the reference, and not for each subsequent use of the
8
// reference.
9
//
10
// This test fails with G++ 1.35.0- (pre-release).
11
// Reported 4/4/89 by Kim Smith
12
 
13
extern "C" int printf (const char *, ...);
14
 
15
struct base {
16
        mutable int data_member;
17
 
18
        base () {}
19
        void function_member () const;
20
};
21
 
22
base base_object;
23
 
24
base base_returning_function ();
25
 
26
int call_count = 0;
27
 
28
int main ()
29
{
30
        const base& base_ref = base_returning_function ();
31
 
32
        base_ref.function_member ();
33
        base_ref.function_member ();
34
        base_ref.data_member  = 99;
35
 
36
        if (call_count == 1)
37
          printf ("PASS\n");
38
        else
39
          { printf ("FAIL\n"); return 1; }
40
 
41
        return 0;
42
}
43
 
44
base base_returning_function ()
45
{
46
        base local_base_object;
47
 
48
        call_count++;
49
        return local_base_object;
50
}
51
 
52
void base::function_member () const
53
{
54
}

powered by: WebSVN 2.1.0

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