summaryrefslogtreecommitdiffstats
path: root/gcc/testsuite/gcc.dg/uninit-4.c
blob: d39ecac77c4f688aab8f8e58444256e7da846e71 (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
50
51
52
/* Spurious uninit variable warnings, case 4.
   Simplified version of cppexp.c (cpp_parse_expr).

   This one is really fragile, it gets it right if you take out case
   1, or if the structure is replaced by an int, or if the structure
   has fewer members (!) */

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

extern void abort (void);

struct operation {
    short op;
    char rprio;
    char flags;
    char unsignedp;
    long value;
};

extern struct operation cpp_lex (void);

void
cpp_parse_expr (void)
{
  int rprio; /* { dg-bogus "rprio" "uninitialized variable warning PR19833" } */
  struct operation op;

  for (;;)
    {
      op = cpp_lex ();

      switch (op.op)
	{
	case 0:
	  break;
	case 1:
	  return;
	case 2:
	  rprio = 1;
	  break;
	default:
	  return;
	}

      if (op.op == 0)
	return;

      if (rprio != 1)
	abort();
    }
}
OpenPOWER on IntegriCloud