From 7261c8f66736409cf38d776b9a2008c5be0773dc Mon Sep 17 00:00:00 2001 From: rillig Date: Sun, 28 Mar 2021 15:12:20 +0000 Subject: [PATCH] tests/lint: add test for struct initialization in traditional C --- tests/usr.bin/xlint/lint1/msg_188.c | 26 ++++++++++++++++++++++---- tests/usr.bin/xlint/lint1/msg_188.exp | 9 ++++++++- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/tests/usr.bin/xlint/lint1/msg_188.c b/tests/usr.bin/xlint/lint1/msg_188.c index 05e7ae353bcb..a4d45ebcbd56 100644 --- a/tests/usr.bin/xlint/lint1/msg_188.c +++ b/tests/usr.bin/xlint/lint1/msg_188.c @@ -1,7 +1,25 @@ -/* $NetBSD: msg_188.c,v 1.2 2021/02/21 09:07:58 rillig Exp $ */ +/* $NetBSD: msg_188.c,v 1.3 2021/03/28 15:12:20 rillig Exp $ */ # 3 "msg_188.c" -// Test for message: no automatic aggregate initialization in traditional C [188] +/* Test for message: no automatic aggregate initialization in traditional C [188] */ -TODO: "Add example code that triggers the above message." /* expect: 249 */ -TODO: "Add example code that almost triggers the above message." +/* lint1-flags: -tw */ + +struct point { + int x; + int y; +}; + +struct point global = { + 3, + 4, +}; + +void +function() +{ + struct point local = { /* expect: 188 */ + 3, + 4, + }; +} diff --git a/tests/usr.bin/xlint/lint1/msg_188.exp b/tests/usr.bin/xlint/lint1/msg_188.exp index cc0127ce56e9..ab34dd5a8367 100644 --- a/tests/usr.bin/xlint/lint1/msg_188.exp +++ b/tests/usr.bin/xlint/lint1/msg_188.exp @@ -1 +1,8 @@ -msg_188.c(6): error: syntax error ':' [249] +(1): warning: 'long double' is illegal in traditional C [266] +(1): warning: function prototypes are illegal in traditional C [270] +(2): warning: 'long double' is illegal in traditional C [266] +(2): warning: function prototypes are illegal in traditional C [270] +(3): warning: 'long double' is illegal in traditional C [266] +(3): warning: 'long double' is illegal in traditional C [266] +(3): warning: function prototypes are illegal in traditional C [270] +msg_188.c(21): warning: no automatic aggregate initialization in traditional C [188]