summaryrefslogtreecommitdiff
path: root/regress/usr.bin/xlint/test-6.c
blob: 95bd7cef1514c1151dfd38cfa5fa468bd82cbb61 (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
/*      $OpenBSD: test-6.c,v 1.1 2005/11/30 19:39:03 cloder Exp $ */

/*
 * Placed in the public domain by Chad Loder <cloder@openbsd.org>.
 *
 * Test c99 predifined identifier __func__
 */
#include <string.h>

/* ARGSUSED */
int
main(int argc, char* argv[])
{
	/* c99 implicitly defines: static const char __func__[] = "main"; */
	static const char foo[] = "main";
	char c;

	if (strcmp(foo, __func__) == 0)
		return 1;

	__func__[0] = 'a';	/* warning: const (not an lvalue) */
	c = __func__[4];	/* ok (c == '\0') */
	c = __func__[5];	/* warning: out of bonds */

	c++;
	return 0;
}