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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [ext/] [cleanup-3.C] - Blame information for rev 696

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

Line No. Rev Author Line
1 693 jeremybenn
/* { dg-do run } */
2
/* { dg-options "" } */
3
/* Verify that the cleanup handler receives the proper contents
4
   of the variable.  */
5
 
6
extern "C" void exit(int);
7
extern "C" void abort(void);
8
 
9
static int expected;
10
 
11
static void
12
handler(int *p)
13
{
14
  if (*p != expected)
15
    abort ();
16
}
17
 
18
static void __attribute__((noinline))
19
bar(void)
20
{
21
}
22
 
23
static void doit(int x, int y)
24
{
25
  int r __attribute__((cleanup (handler)));
26
  if (x < y)
27
    {
28
      r = 0;
29
      return;
30
    }
31
 
32
  bar();
33
  r = x + y;
34
}
35
 
36
int main()
37
{
38
  expected = 0;
39
  doit (1, 2);
40
 
41
  expected = 3;
42
  doit (2, 1);
43
 
44
  return 0;
45
}

powered by: WebSVN 2.1.0

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