Module Name: src
Committed By: rillig
Date: Fri Jul 21 05:51:12 UTC 2023
Modified Files:
src/tests/usr.bin/xlint/lint1: msg_181.c
Log Message:
tests/lint: document an example of a non-constant initializer
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/xlint/lint1/msg_181.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/usr.bin/xlint/lint1/msg_181.c
diff -u src/tests/usr.bin/xlint/lint1/msg_181.c:1.5 src/tests/usr.bin/xlint/lint1/msg_181.c:1.6
--- src/tests/usr.bin/xlint/lint1/msg_181.c:1.5 Tue Mar 28 14:44:35 2023
+++ src/tests/usr.bin/xlint/lint1/msg_181.c Fri Jul 21 05:51:12 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_181.c,v 1.5 2023/03/28 14:44:35 rillig Exp $ */
+/* $NetBSD: msg_181.c,v 1.6 2023/07/21 05:51:12 rillig Exp $ */
# 3 "msg_181.c"
// Test for message: {}-enclosed initializer required [181]
@@ -8,3 +8,16 @@
/* expect+1: error: {}-enclosed initializer required [181] */
struct { int x; } missing_braces = 3;
struct { int x; } including_braces = { 3 };
+
+
+// C11 6.6p7 requires the initializer of an object with static storage duration
+// to be a constant expression or an address constant, and a compound literal
+// is neither. C11 6.6p10 allows an implementation to accept "other forms of
+// constant expressions", and GCC accepts compound literals that contain only
+// constant expressions.
+struct number {
+ int value;
+} num = (struct number){
+ .value = 3,
+};
+/* expect-1: error: {}-enclosed initializer required [181] */