msg_383.c revision 1.4
1/*	$NetBSD: msg_383.c,v 1.4 2025/05/04 09:40:03 rillig Exp $	*/
2# 3 "msg_383.c"
3
4// Test for message: passing '%s' as argument %d to '%s' discards '%s' [383]
5
6/* lint1-extra-flags: -X 351 */
7
8void sink_char(char *, const char *, volatile char *, const volatile char *);
9void sink_int(int *, const int *, volatile int *, const volatile int *);
10
11void (*indirect_char)(char *, const char *, volatile char *, const volatile char *);
12
13struct {
14	void (*member_char)(char *, const char *, volatile char *, const volatile char *);
15} doubly_indirect;
16
17void
18caller(const volatile char *cvcp, const volatile int *cvip, int (*fn)(void))
19{
20	/* expect+3: warning: passing 'pointer to const volatile char' as argument 1 to 'sink_char' discards 'const volatile' [383] */
21	/* expect+2: warning: passing 'pointer to const volatile char' as argument 2 to 'sink_char' discards 'volatile' [383] */
22	/* expect+1: warning: passing 'pointer to const volatile char' as argument 3 to 'sink_char' discards 'const' [383] */
23	sink_char(cvcp, cvcp, cvcp, cvcp);
24	/* expect+3: warning: passing 'pointer to const volatile int' as argument 1 to 'sink_int' discards 'const volatile' [383] */
25	/* expect+2: warning: passing 'pointer to const volatile int' as argument 2 to 'sink_int' discards 'volatile' [383] */
26	/* expect+1: warning: passing 'pointer to const volatile int' as argument 3 to 'sink_int' discards 'const' [383] */
27	sink_int(cvip, cvip, cvip, cvip);
28	/* expect+4: warning: converting 'pointer to function(void) returning int' to incompatible 'pointer to char' for argument 1 [153] */
29	/* expect+3: warning: converting 'pointer to function(void) returning int' to incompatible 'pointer to const char' for argument 2 [153] */
30	/* expect+2: warning: converting 'pointer to function(void) returning int' to incompatible 'pointer to volatile char' for argument 3 [153] */
31	/* expect+1: warning: converting 'pointer to function(void) returning int' to incompatible 'pointer to const volatile char' for argument 4 [153] */
32	sink_char(fn, fn, fn, fn);
33
34	/* expect+3: warning: passing 'pointer to const volatile char' as argument 1 to 'indirect_char' discards 'const volatile' [383] */
35	/* expect+2: warning: passing 'pointer to const volatile char' as argument 2 to 'indirect_char' discards 'volatile' [383] */
36	/* expect+1: warning: passing 'pointer to const volatile char' as argument 3 to 'indirect_char' discards 'const' [383] */
37	indirect_char(cvcp, cvcp, cvcp, cvcp);
38
39	/* expect+3: warning: passing 'pointer to const volatile char' as argument 1 to 'function(pointer to char, pointer to const char, pointer to volatile char, pointer to const volatile char) returning void' discards 'const volatile' [383] */
40	/* expect+2: warning: passing 'pointer to const volatile char' as argument 2 to 'function(pointer to char, pointer to const char, pointer to volatile char, pointer to const volatile char) returning void' discards 'volatile' [383] */
41	/* expect+1: warning: passing 'pointer to const volatile char' as argument 3 to 'function(pointer to char, pointer to const char, pointer to volatile char, pointer to const volatile char) returning void' discards 'const' [383] */
42	doubly_indirect.member_char(cvcp, cvcp, cvcp, cvcp);
43}
44
45
46typedef int array[8];
47typedef const int *pointer_to_const_array;
48
49// The 'const' applies to the pointer target, making it 'const int *'.
50int const_array_callee(const array);
51
52static inline int
53const_array_caller(pointer_to_const_array ptr)
54{
55	return const_array_callee(ptr);
56}
57