1/* This testcase violates the OpenMP requirements, as nested functions
2   access the original variables.
3   We test it just to make sure we don't ICE on it.  */
4/* { dg-do compile } */
5/* { dg-options "-O2 -fopenmp" } */
6
7extern void abort (void);
8extern int omp_get_thread_num ();
9extern void omp_set_dynamic (int);
10
11int
12main (void)
13{
14  int j = 0, k = 6, l = 7, m = 8;
15  void foo (void)
16  {
17    int i = 5;
18    int bar (void)
19    {
20      return i + 1 + (j > 100 ? 10000 : 0);
21    }
22#pragma omp sections private (i)
23    {
24#pragma omp section
25      {
26	i = 6;
27	if (bar () != 6)
28#pragma omp atomic
29	  ++j;
30      }
31#pragma omp section
32      {
33	if (bar () != 6)
34#pragma omp atomic
35	  ++j;
36      }
37    }
38    if (k != 6 || l != 7 || m != 8)
39#pragma omp atomic
40      ++j;
41  }
42  omp_set_dynamic (0);
43#pragma omp parallel num_threads (2) firstprivate (k) shared (l) private (m)
44  {
45    if (omp_get_thread_num () != 0)
46      k += omp_get_thread_num ();
47    m = 9;
48    foo ();
49  }
50  if (j)
51    abort ();
52  return 0;
53}
54