summaryrefslogtreecommitdiff
path: root/regress/usr.bin/xlint/test-17.c
blob: 009e2b20519b2ec367d0fb8be172326552688600 (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
 /*	$OpenBSD: test-17.c,v 1.3 2006/04/25 01:31:46 cloder Exp $	*/

/*
 * Placed in the public domain by Chad Loder <cloder@openbsd.org>.
 *
 * Test lint dealing with unreachable break statements.
 */

/* ARGSUSED */
int
main(int argc, char* argv[])
{
	int a = 0;

	switch (argc)
	{
	case 1:
		a = 1;
		return 1;
		break; /* should not warn */
	case 2:
		a = 2;
		while (a < 5) {
			a++;
			break;
			break; /* should warn */
		}
		break;
	case 3:
		switch (a) {
		case 0:
			break;
		}
	default:
		break;
	}

	while (argc < 5) {
		if (argc ) {
			return 1;
			break; /* should warn */
		}

		argc++;
		break;
	}

	return a;
}