msg_102.c revision 1.5
11.5Srillig/* $NetBSD: msg_102.c,v 1.5 2023/06/30 09:21:52 rillig Exp $ */ 21.1Srillig# 3 "msg_102.c" 31.1Srillig 41.4Srillig// Test for message: illegal use of member '%s' [102] 51.1Srillig 61.3Srillig// Anonymous members are defined in C11 6.7.2.1p2. 71.3Srillig 81.5Srilligstruct unrelated { 91.3Srillig union { 101.3Srillig struct { 111.3Srillig unsigned bit_0:1; 121.3Srillig unsigned bit_1:1; 131.3Srillig }; 141.3Srillig unsigned bits; 151.3Srillig }; 161.3Srillig}; 171.3Srillig 181.5Srilligstruct bit_fields_and_bits { 191.5Srillig union { 201.5Srillig struct { 211.5Srillig unsigned bf_bit_0:1; 221.5Srillig unsigned bf_bit_1:1; 231.5Srillig }; 241.5Srillig unsigned bf_bits; 251.5Srillig }; 261.5Srillig}; 271.5Srillig 281.5Srilligstatic struct unrelated *u1, *u2; 291.5Srilligstatic struct bit_fields_and_bits *b1, *b2; 301.5Srillig 311.3Srilligstatic inline _Bool 321.5Srilligeq(int x) 331.3Srillig{ 341.3Srillig /* 351.3Srillig * TODO: Once this is fixed, enable lint in 361.3Srillig * external/mit/xorg/lib/dri.old/Makefile again. 371.3Srillig */ 381.5Srillig 391.5Srillig if (x == 0) 401.5Srillig /* expect+2: error: illegal use of member 'bits' [102] */ 411.5Srillig /* expect+1: error: illegal use of member 'bits' [102] */ 421.5Srillig return u1->bits == u2->bits; 431.5Srillig 441.5Srillig /* 451.5Srillig * The struct does not have a member named 'bits'. There's another 461.5Srillig * struct with a member of that name, and in traditional C, it was 471.5Srillig * possible but discouraged to access members of other structs via 481.5Srillig * their plain name. 491.5Srillig */ 501.4Srillig /* expect+2: error: illegal use of member 'bits' [102] */ 511.4Srillig /* expect+1: error: illegal use of member 'bits' [102] */ 521.5Srillig return b1->bits == b2->bits; 531.3Srillig} 54