lint: add details to message about too many initializers

This commit is contained in:
rillig 2024-05-09 20:53:13 +00:00
parent 98b1d3b32e
commit 2d37fed27b
4 changed files with 12 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: d_c99_init.c,v 1.48 2024/03/30 16:47:45 rillig Exp $ */
/* $NetBSD: d_c99_init.c,v 1.49 2024/05/09 20:53:13 rillig Exp $ */
# 3 "d_c99_init.c"
/*
@ -23,7 +23,7 @@ typedef struct any {
int scalar_without_braces = 3;
int scalar_with_optional_braces = { 3 };
int scalar_with_too_many_braces = {{ 3 }};
/* expect+1: error: too many initializers [174] */
/* expect+1: error: too many initializers for 'int' [174] */
int scalar_with_too_many_initializers = { 3, 5 };

View File

@ -1,7 +1,7 @@
/* $NetBSD: msg_174.c,v 1.6 2023/07/07 19:45:22 rillig Exp $ */
/* $NetBSD: msg_174.c,v 1.7 2024/05/09 20:53:13 rillig Exp $ */
# 3 "msg_174.c"
// Test for message: too many initializers [174]
// Test for message: too many initializers for '%s' [174]
/* lint1-extra-flags: -X 351 */
@ -11,7 +11,7 @@ example(void)
/* A single pair of braces is always allowed. */
int n = { 13 };
/* expect+1: error: too many initializers [174] */
/* expect+1: error: too many initializers for 'int' [174] */
int too_many = { 17, 19 };
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: err.c,v 1.241 2024/04/27 10:08:54 rillig Exp $ */
/* $NetBSD: err.c,v 1.242 2024/05/09 20:53:13 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
__RCSID("$NetBSD: err.c,v 1.241 2024/04/27 10:08:54 rillig Exp $");
__RCSID("$NetBSD: err.c,v 1.242 2024/05/09 20:53:13 rillig Exp $");
#endif
#include <limits.h>
@ -229,7 +229,7 @@ static const char *const msgs[] = {
"cannot assign to '%s' from '%s'", // 171
"too many struct/union initializers", // 172
"too many array initializers, expected %d", // 173
"too many initializers", // 174
"too many initializers for '%s'", // 174
"initialization of incomplete type '%s'", // 175
"", /* no longer used */ // 176
"non-constant initializer", // 177

View File

@ -1,4 +1,4 @@
/* $NetBSD: init.c,v 1.268 2024/03/30 17:12:26 rillig Exp $ */
/* $NetBSD: init.c,v 1.269 2024/05/09 20:53:13 rillig Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID)
__RCSID("$NetBSD: init.c,v 1.268 2024/03/30 17:12:26 rillig Exp $");
__RCSID("$NetBSD: init.c,v 1.269 2024/05/09 20:53:13 rillig Exp $");
#endif
#include <stdlib.h>
@ -530,8 +530,8 @@ warn_too_many_initializers(designator_kind kind, const type_t *tp)
/* too many array initializers, expected %d */
error(173, tp->u.dimension);
} else
/* too many initializers */
error(174);
/* too many initializers for '%s' */
error(174, type_name(tp));
}
static bool