msg_171.c revision 1.6 1 1.6 rillig /* $NetBSD: msg_171.c,v 1.6 2021/03/23 18:40:50 rillig Exp $ */
2 1.1 rillig # 3 "msg_171.c"
3 1.1 rillig
4 1.4 rillig // Test for message: cannot assign to '%s' from '%s' [171]
5 1.1 rillig
6 1.2 rillig struct s {
7 1.2 rillig int member;
8 1.2 rillig };
9 1.2 rillig
10 1.2 rillig /*ARGSUSED*/
11 1.2 rillig void
12 1.2 rillig example(int i, void *vp, struct s *s)
13 1.2 rillig {
14 1.2 rillig i = *s; /* expect: 171 */
15 1.2 rillig *s = i; /* expect: 171 */
16 1.2 rillig
17 1.2 rillig vp = *s; /* expect: 171 */
18 1.2 rillig *s = vp; /* expect: 171 */
19 1.2 rillig }
20 1.3 rillig
21 1.3 rillig /*
22 1.3 rillig * C99 6.5.2.5 says that a compound literal evaluates to an unnamed object
23 1.3 rillig * with automatic storage duration, like any normal named object. It is an
24 1.3 rillig * lvalue, which means that it is possible to take the address of the object.
25 1.3 rillig * Seen in external/mpl/bind/dist/lib/dns/rbtdb.c, update_rrsetstats.
26 1.6 rillig *
27 1.6 rillig * Before init.c 1.111 from 2021-03-23, lint could not handle these nested
28 1.6 rillig * initializations (the outer one for the variable 'p', the inner one for the
29 1.6 rillig * compound literal) and wrongly complained about a type mismatch between
30 1.6 rillig * 'struct point' and 'pointer to struct point'.
31 1.3 rillig */
32 1.3 rillig void
33 1.3 rillig pointer_to_compound_literal(void)
34 1.3 rillig {
35 1.3 rillig struct point {
36 1.3 rillig int x;
37 1.3 rillig int y;
38 1.3 rillig };
39 1.3 rillig struct point *p = &(struct point){
40 1.3 rillig 12, 5,
41 1.6 rillig };
42 1.3 rillig }
43