summaryrefslogtreecommitdiff
path: root/regress/usr.bin/xlint/test-20.c
blob: cb3fd7d3f99f8f55725fd916c45d70407306e647 (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
53
54
55
56
57
58
59
60
61
/*      $OpenBSD: test-20.c,v 1.2 2006/05/03 18:23:17 otto Exp $ */

/*
 * Placed in the public domain by Otto Moerbeek <otto@drijf.net>.
 *
 * Test the 'expression has null effect warning'
 */

#include <assert.h>

int f(int x,...)
{
	int p;
	char *q = 0;
	int i = (1,33), j = (p=0,p), k = (i+j, i=0);

	int a = i < 1 ? j : i, b = 2, t;

	t = a, a = b, b = t;

	1 + b, t = a, a = b, b = t, a + 1, b - 1;

	a + t, t = b;

	a + 1;

	b + 1, t = t;

	t = t, b + 1;

	1 + a;

	1,2,3,4,5;

	a = (1,(b=2),3,4,5);

	if (a + 1, b)
		a = 2;

	a ? b=1 : t;

	a + 1, b = 1, t + 1;

	a = (1,b,f(a,(a,b),t));

	*q = 0, *q = 0, *q = 0, *q = 0, *q = 0;

	*q + 0, *q = 0, *q = 0, *q = 0, *q = 0;

	q ? q = 0 : q++;

	assert(p == j);

	0;

	(void)0;

	j = j < 0 ? j + 1 : j + 2;

	return k + k, x;
}