2013-10-21 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / cleanup-3.c
blobb5b01fd59051bc4951ed4b719b023aa1aef554bc
1 /* { dg-do run } */
2 /* { dg-options "" } */
3 /* Verify that the cleanup handler receives the proper contents
4 of the variable. */
6 extern void exit(int);
7 extern void abort(void);
9 static int expected;
11 static void
12 handler(int *p)
14 if (*p != expected)
15 abort ();
18 static void __attribute__((noinline))
19 bar(void)
23 static void doit(int x, int y)
25 int r __attribute__((cleanup (handler)));
26 if (x < y)
28 r = 0;
29 return;
32 bar();
33 r = x + y;
36 int main()
38 expected = 0;
39 doit (1, 2);
41 expected = 3;
42 doit (2, 1);
44 return 0;