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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [init/] [init-ref2.C] - Blame information for rev 774

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

Line No. Rev Author Line
1 693 jeremybenn
// Submitted by Jason Merrill 
2
// Test for proper handling of local static references.
3
// { dg-do run }
4
 
5
int r;
6
 
7
int c;
8
int f ()
9
{
10
  // Test that we only initialize i once.
11
  if (++c > 1)
12
    ++r;
13
  return 42;
14
}
15
 
16
const int *p;
17
void g ()
18
{
19
  static const int &i = f();
20
 
21
  // Test that i points to the same place in both calls.
22
  if (p && p != &i)
23
    ++r;
24
  // Test that if so, it points to static data.
25
  if (i != 42)
26
    ++r;
27
 
28
  p = &i;
29
}
30
 
31
void h ()
32
{
33
  int arr[] = { 1, 1, 1, 1, 1, 1, 1 };
34
  g ();
35
}
36
 
37
int main ()
38
{
39
  g ();
40
  h ();
41
  return r;
42
}

powered by: WebSVN 2.1.0

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