summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/uninit-8-O0.c
blob: b386896c7eaad8969cff0e82cd9883aba3d387d0 (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
/* Uninitialized variable warning tests...
   Inspired by part of optabs.c:expand_binop.
   May be the same as uninit-1.c.  */

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

#include <limits.h>

void
add_bignums (int *out, int *x, int *y)
{
    int p, sum;
    int carry; /* { dg-bogus "carry" "uninitialized variable warning" } */

    p = 0;
    for (; *x; x++, y++, out++, p++)
    {
	if (p)
	    sum = *x + *y + carry;
	else
	    sum = *x + *y;

	if (sum < 0)
	{
	    carry = 1;
	    sum -= INT_MAX;
	}
	else
	    carry = 0;
    }
}