1*5008d0bcSrillig /* $NetBSD: msg_181.c,v 1.7 2023/07/21 06:02:07 rillig Exp $ */ 2a0a15c14Srillig # 3 "msg_181.c" 3a0a15c14Srillig 4*5008d0bcSrillig // Test for message: {}-enclosed or constant initializer of type '%s' required [181] 5a0a15c14Srillig 6b2baa501Srillig /* lint1-extra-flags: -X 351 */ 7b2baa501Srillig 8*5008d0bcSrillig /* expect+1: error: {}-enclosed or constant initializer of type 'struct <unnamed>' required [181] */ 965e5c21bSrillig struct { int x; } missing_braces = 3; 10a1441321Srillig struct { int x; } including_braces = { 3 }; 116d841877Srillig 126d841877Srillig 136d841877Srillig // C11 6.6p7 requires the initializer of an object with static storage duration 146d841877Srillig // to be a constant expression or an address constant, and a compound literal 156d841877Srillig // is neither. C11 6.6p10 allows an implementation to accept "other forms of 166d841877Srillig // constant expressions", and GCC accepts compound literals that contain only 176d841877Srillig // constant expressions. 186d841877Srillig struct number { 196d841877Srillig int value; 206d841877Srillig } num = (struct number){ 216d841877Srillig .value = 3, 226d841877Srillig }; 23*5008d0bcSrillig /* expect-1: error: {}-enclosed or constant initializer of type 'struct number' required [181] */ 24