summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/nested-func-2.c
blob: 14f14c67e85045114fa16adf00e65fa0560ac7f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* PR middle-end/18820 */
/* Check that we reject nested functions as initializers
   of static variables.  */

/* { dg-do compile } */
/* { dg-options "" } */

struct S {
  void (*f)(int);
};

extern void baz(struct S *);
extern void p(int);

void foo(void)
{
  int u;

  void bar(int val)
    {
      u = val;
    }

  static struct S s = { bar }; /* { dg-error "(is not constant)|(near initialization)" } */

  baz(&s);
  p(u);
}