msg_181.c revision 1.6
1/* $NetBSD: msg_181.c,v 1.6 2023/07/21 05:51:12 rillig Exp $ */ 2# 3 "msg_181.c" 3 4// Test for message: {}-enclosed initializer required [181] 5 6/* lint1-extra-flags: -X 351 */ 7 8/* expect+1: error: {}-enclosed initializer required [181] */ 9struct { int x; } missing_braces = 3; 10struct { int x; } including_braces = { 3 }; 11 12 13// C11 6.6p7 requires the initializer of an object with static storage duration 14// to be a constant expression or an address constant, and a compound literal 15// is neither. C11 6.6p10 allows an implementation to accept "other forms of 16// constant expressions", and GCC accepts compound literals that contain only 17// constant expressions. 18struct number { 19 int value; 20} num = (struct number){ 21 .value = 3, 22}; 23/* expect-1: error: {}-enclosed initializer required [181] */ 24