summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/nested-func-1.c
blob: cb26e895e5c0d6e13c6febce90a86264fa2b002c (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
29
30
31
32
33
34
35
/* Test for proper errors for break and continue in nested functions.  */
/* Origin: Joseph Myers <jsm@polyomino.org.uk> */
/* { dg-do compile } */
/* { dg-options "" } */

void
foo (int a)
{
  switch (a) {
    void bar1 (void) { break; } /* { dg-error "break statement" "break switch 1" } */
  }
  switch (a) {
  case 0:
    (void) 0;
    void bar2 (void) { break; } /* { dg-error "break statement" "break switch 2" } */
  }
  while (1) {
    void bar3 (void) { break; } /* { dg-error "break statement" "break while" } */
  }
  do {
    void bar4 (void) { break; } /* { dg-error "break statement" "break do" } */
  } while (1);
  for (;;) {
    void bar5 (void) { break; } /* { dg-error "break statement" "break for" } */
  }
  while (1) {
    void bar6 (void) { continue; } /* { dg-error "continue statement" "continue while" } */
  }
  do {
    void bar7 (void) { continue; } /* { dg-error "continue statement" "continue do" } */
  } while (1);
  for (;;) {
    void bar8 (void) { continue; } /* { dg-error "continue statement" "continue for" } */
  }
}