2018-06-05 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / cleanup-4.c
bloba5487553d2ba399fad5055cfab58661d2dda36d8
1 /* { dg-do run } */
2 /* { dg-options "" } */
3 /* Verify cleanup execution on non-trivial exit from a block. */
5 extern void exit(int);
6 extern void abort(void);
8 static int counter;
10 static void
11 handler(int *p)
13 counter += *p;
16 static void __attribute__((noinline))
17 bar(void)
21 static void doit(int n, int n2)
23 int i;
24 for (i = 0; i < n; ++i)
26 int dummy __attribute__((cleanup (handler))) = i;
27 if (i == n2)
28 break;
29 bar();
33 int main()
35 doit (10, 6);
36 if (counter != 0 + 1 + 2 + 3 + 4 + 5 + 6)
37 abort ();
38 return 0;