// { dg-do run }
|
// { dg-do run }
|
// { dg-options "-w" }
|
// { dg-options "-w" }
|
// GROUPS passed references
|
// GROUPS passed references
|
// Check that if a reference is initialized to refer to a value
|
// Check that if a reference is initialized to refer to a value
|
// which is returned from a function call, the actual call to
|
// which is returned from a function call, the actual call to
|
// the function is only invoked for the original initialization
|
// the function is only invoked for the original initialization
|
// of the reference, and not for each subsequent use of the
|
// of the reference, and not for each subsequent use of the
|
// reference.
|
// reference.
|
//
|
//
|
// This test fails with G++ 1.35.0- (pre-release).
|
// This test fails with G++ 1.35.0- (pre-release).
|
// Reported 4/4/89 by Kim Smith
|
// Reported 4/4/89 by Kim Smith
|
|
|
extern "C" int printf (const char *, ...);
|
extern "C" int printf (const char *, ...);
|
|
|
struct base {
|
struct base {
|
mutable int data_member;
|
mutable int data_member;
|
|
|
base () {}
|
base () {}
|
void function_member () const;
|
void function_member () const;
|
};
|
};
|
|
|
base base_object;
|
base base_object;
|
|
|
base base_returning_function ();
|
base base_returning_function ();
|
|
|
int call_count = 0;
|
int call_count = 0;
|
|
|
int main ()
|
int main ()
|
{
|
{
|
const base& base_ref = base_returning_function ();
|
const base& base_ref = base_returning_function ();
|
|
|
base_ref.function_member ();
|
base_ref.function_member ();
|
base_ref.function_member ();
|
base_ref.function_member ();
|
base_ref.data_member = 99;
|
base_ref.data_member = 99;
|
|
|
if (call_count == 1)
|
if (call_count == 1)
|
printf ("PASS\n");
|
printf ("PASS\n");
|
else
|
else
|
{ printf ("FAIL\n"); return 1; }
|
{ printf ("FAIL\n"); return 1; }
|
|
|
return 0;
|
return 0;
|
}
|
}
|
|
|
base base_returning_function ()
|
base base_returning_function ()
|
{
|
{
|
base local_base_object;
|
base local_base_object;
|
|
|
call_count++;
|
call_count++;
|
return local_base_object;
|
return local_base_object;
|
}
|
}
|
|
|
void base::function_member () const
|
void base::function_member () const
|
{
|
{
|
}
|
}
|
|
|