aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.8/gcc/testsuite/gcc.dg/uninit-3-O0.c
blob: d3dcf14edece29da15d9e07a9ae09eb852c58266 (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
/* Spurious uninit variable warnings, case 3.
   Inspired by cppexp.c (parse_charconst) */
/* { dg-do compile } */
/* { dg-options "-Wuninitialized" } */

extern void error (char *);

int
parse_charconst (const char *start, const char *end)
{
  int c; /* { dg-bogus "c" "uninitialized variable warning" } */
  int nchars, retval;

  nchars = 0;
  retval = 0;
  while (start < end)
    {
      c = *start++;
      if (c == '\'')
	break;
      nchars++;
      retval += c;
      retval <<= 8;
    }

  if (nchars == 0)
    return 0;

  if (c != '\'')
    error ("malformed character constant");

  return retval;
}