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