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