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
77
78
79
80
81
82
83
84
85
86
87
|
/* $NetBSD: d_init_array_using_string.c,v 1.13 2023/03/28 14:44:34 rillig Exp $ */
# 3 "d_init_array_using_string.c"
/*
* Test initialization of arrays and pointers by string literals.
*/
/* lint1-extra-flags: -X 351 */
void sink(const void *);
void
test_assignment_initialization(void)
{
const char *cs_match = "";
const int *ws_match = L"";
/* expect+1: warning: illegal combination of 'pointer to const char' and 'pointer to int', op 'init' [124] */
const char *cs_mismatch = L"";
/* expect+1: warning: illegal combination of 'pointer to const int' and 'pointer to char', op 'init' [124] */
const int *ws_mismatch = "";
}
void
test_pointer_initialization_in_struct(void)
{
struct cs_ws {
const char *cs;
const int *ws;
};
struct cs_ws type_match = {
"",
L"",
};
struct cs_ws type_mismatch = {
/* expect+1: warning: illegal combination of 'pointer to const char' and 'pointer to int', op 'init' [124] */
L"",
/* expect+1: warning: illegal combination of 'pointer to const int' and 'pointer to char', op 'init' [124] */
"",
};
struct cs_ws extra_braces = {
{ "" },
{ L"" },
};
}
void
test_array_initialization_in_struct(void)
{
struct cs_ws {
const char cs[10];
const int ws[10];
};
struct cs_ws type_match = {
"",
L"",
};
struct cs_ws type_mismatch = {
/* expect+1: warning: illegal combination of integer 'char' and pointer 'pointer to int' [183] */
L"",
/* expect+1: warning: illegal combination of integer 'char' and pointer 'pointer to char' [183] */
"",
};
struct cs_ws no_terminating_null = {
"0123456789",
L"0123456789",
};
struct cs_ws too_many_characters = {
/* expect+1: warning: string literal too long (11) for target array (10) [187] */
"0123456789X",
/* expect+1: warning: string literal too long (11) for target array (10) [187] */
L"0123456789X",
};
struct cs_ws extra_braces = {
{ "" },
{ L"" },
};
}
|