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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [g++.dg/] [init/] [init-ref2.C] - Diff between revs 149 and 154

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 149 Rev 154
// Submitted by Jason Merrill 
// Submitted by Jason Merrill 
// Test for proper handling of local static references.
// Test for proper handling of local static references.
// { dg-do run }
// { dg-do run }
int r;
int r;
int c;
int c;
int f ()
int f ()
{
{
  // Test that we only initialize i once.
  // Test that we only initialize i once.
  if (++c > 1)
  if (++c > 1)
    ++r;
    ++r;
  return 42;
  return 42;
}
}
const int *p;
const int *p;
void g ()
void g ()
{
{
  static const int &i = f();
  static const int &i = f();
  // Test that i points to the same place in both calls.
  // Test that i points to the same place in both calls.
  if (p && p != &i)
  if (p && p != &i)
    ++r;
    ++r;
  // Test that if so, it points to static data.
  // Test that if so, it points to static data.
  if (i != 42)
  if (i != 42)
    ++r;
    ++r;
  p = &i;
  p = &i;
}
}
void h ()
void h ()
{
{
  int arr[] = { 1, 1, 1, 1, 1, 1, 1 };
  int arr[] = { 1, 1, 1, 1, 1, 1, 1 };
  g ();
  g ();
}
}
int main ()
int main ()
{
{
  g ();
  g ();
  h ();
  h ();
  return r;
  return r;
}
}
 
 

powered by: WebSVN 2.1.0

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