aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/uninit-pr102403.c
blob: 1e62e988fd64c2daf62c5a440ea846b69f1febb9 (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
40
41
42
43
44
45
46
47
48
49
/* PR middle-end/102403 - ICE in init_from_control_deps, at
   gimple-predicate-analysis.cc:2364
   { dg-do compile }
   { dg-options "-O2 -Wall" } */

int __fmaf (void)
{
  int a = 0;
  int b, c, d, e, f;

  int r = 0;

  switch (b)        // { dg-warning "-Wuninitialized" }
    {
    default:
      c |= 1;

    case 0:
      if (c == 0)
	a = 1;

      switch (d) {
      case 15:
	f = c;
	break;

      case 11:
      case 6:
      case 4:
	f = c;
      case 10:
	e = a;
      }

      if (e == 0)   // { dg-warning "-Wmaybe-uninitialized" }
  	f = 0;

      r = f;
  }

  // The return statement below gets the unhelpful warning:
  // 'f' may be used uninitialized in this function [-Wmaybe-uninitialized]
  return r;
}

/* Prune out warnings issued on the wrong lines, such as:
   uninit-pr102403.c:9:13: warning: ā€˜d’ is used uninitialized [-Wuninitialized]
   { dg-prune-output "-Wuninitialized" }
   { dg-prune-output "-Wmaybe-uninitialized" } */