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
|
/* $NetBSD: msg_155.c,v 1.12 2023/03/28 14:44:35 rillig Exp $ */
# 3 "msg_155.c"
// Test for message: passing '%s' to incompatible '%s', arg #%d [155]
/* lint1-extra-flags: -X 351 */
void c99_6_7_6_example_a(int);
void c99_6_7_6_example_b(int *);
void c99_6_7_6_example_c(int *[3]);
void c99_6_7_6_example_d(int (*)[3]);
void c99_6_7_6_example_e(int (*)[*]);
/* Wrong type before decl.c 1.256 from 2022-04-01. */
void c99_6_7_6_example_f(int *());
void c99_6_7_6_example_g(int (*)(void));
void c99_6_7_6_example_h(int (*const[])(unsigned int, ...));
struct incompatible {
int member;
};
void
provoke_error_messages(struct incompatible arg)
{
/* expect+1: ... 'int', ... */
c99_6_7_6_example_a(arg);
/* expect+1: ... 'pointer to int', ... */
c99_6_7_6_example_b(arg);
/* C99 says 'array[3] of pointer to int', which is close enough. */
/* expect+1: ... 'pointer to pointer to int', ... */
c99_6_7_6_example_c(arg);
/* expect+1: ... 'pointer to array[3] of int', ... */
c99_6_7_6_example_d(arg);
/* expect+1: ... 'pointer to array[unknown_size] of int', ... */
c99_6_7_6_example_e(arg);
/* Wrong type before decl.c 1.256 from 2022-04-01. */
/* expect+1: ... 'pointer to function() returning pointer to int', ... */
c99_6_7_6_example_f(arg);
/* expect+1: ... 'pointer to function(void) returning int', ... */
c99_6_7_6_example_g(arg);
/* expect+1: ... 'pointer to const pointer to function(unsigned int, ...) returning int', ... */
c99_6_7_6_example_h(arg);
}
extern void sink(struct incompatible);
/*
* The function type_name has a special case for an enum type that has been
* implicitly converted to an int. Such a type is still output as the enum
* type.
*
* XXX: The expressions 'day + 0' and '0 + day' should result in the same
* type.
*/
void
type_name_of_enum(void)
{
enum Day {
MONDAY
} day = MONDAY;
/* expect+1: ... passing 'enum Day' ... */
sink(day);
/* expect+1: ... passing 'enum Day' ... */
sink(day + 0);
/* expect+1: ... passing 'int' ... */
sink(0 + day);
/* expect+1: ... passing 'int' ... */
sink(0);
}
|