summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/ext/label3.C
blob: 604bfdc12c3cb4d4b69798465b5afd3d48b465a0 (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
36
37
38
39
// Bug: we were removing the p = q assignment in dce, and then reinserting
// it *after* the try/catch in out-of-ssa.  Oops.

// testcase reduced from libjava/interpret.cc.

// { dg-do run }
// { dg-options "-O2" }

extern "C" int printf (const char *, ...);

bool b;

int main()
{
  __label__ one, two, done;
  void *labs[] = { &&one, &&two, &&done };
  const void **q = (const void **)labs;
  const void **p = q;

  try
    {
    one:
      printf ("one!\n");
      if (b)
	throw 42;
      goto **p++;

    two:
      printf ("two!\n");
      goto **p++;

    done:
      printf ("done!\n");
    }
  catch (int)
    {
      printf ("caught!\n");
    }
}