File: type-compare.c

package info (click to toggle)
sparse 0.6.4-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,868 kB
  • sloc: ansic: 46,050; sh: 614; python: 301; perl: 293; makefile: 279
file content (76 lines) | stat: -rw-r--r-- 2,154 bytes parent folder | download | duplicates (4)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#define __user		__attribute__((address_space(1)))
#define __safe		__attribute__((safe))
#define __nocast	__attribute__((nocast))
#define __bitwise	__attribute__((bitwise))
#define __noderef	__attribute__((noderef))

int test(void)
{
	if ([int] != [int]) return 1;
	if (!([int] == [int])) return 1;

	if ([int] == [long]) return 1;
	if (!([int] != [long])) return 1;

	if ([int] == [unsigned int]) return 1;
	if (!([int] != [unsigned int])) return 1;

	if ([int] != [int]) return 1;
	if ([typeof(int)] != [int]) return 1;
	if ([int] != [typeof(int)]) return 1;
	if ([typeof(int)] != [typeof(int)]) return 1;

	if ([char] > [short]) return 1;
	if ([short] < [char]) return 1;
	if (!([char] <= [short])) return 1;
	if (!([short] >= [char])) return 1;

	if ([short] > [int]) return 1;
	if ([int] < [short]) return 1;
	if (!([short] <= [int])) return 1;
	if (!([int] >= [short])) return 1;

	if ([int] > [long]) return 1;
	if ([long] < [int]) return 1;
	if (!([int] <= [long])) return 1;
	if (!([long] >= [int])) return 1;

	if ([long] > [long long]) return 1;
	if ([long long] < [long]) return 1;
	if (!([long] <= [long long])) return 1;
	if (!([long long] >= [long])) return 1;

	if ([int *] != [int *]) return 1;
	if ([int *] == [void *]) return 1;

	// qualifiers are ignored
	if ([int] != [const int]) return 1;
	if ([int] != [volatile int]) return 1;

	// but others modifiers are significant
	if ([int] == [int __nocast]) return 1;
	if ([int] == [int __bitwise]) return 1;

	//
	if ([int *] == [const int *]) return 1;
	if ([int *] == [volatile int *]) return 1;
	if ([int *] == [int __user *]) return 1;
	if ([int *] == [int __safe *]) return 1;
	if ([int *] == [int __nocast *]) return 1;
	if ([int *] == [int __bitwise *]) return 1;
	if ([int *] == [int __noderef *]) return 1;

	return 0;
}

/*
 * check-name: type-as-first-class comparison
 * check-description: This test the sparse extension making
 *	types first class citizens which can be compared
 *	for equality (or size for <, >, <=, >=).
 *	See expand.c:compare_types().
 * check-command: test-linearize -Wno-decl $file
 * check-output-ignore
 *
 * check-output-contains: ret\\..*\\$0
 */