lint: add debug logging for C99-style initialization of arrays
No functional change outside debug mode.
This commit is contained in:
parent
59329564e5
commit
d8304c1dc3
|
@ -1,5 +1,5 @@
|
|||
%{
|
||||
/* $NetBSD: cgram.y,v 1.175 2021/03/17 01:53:21 rillig Exp $ */
|
||||
/* $NetBSD: cgram.y,v 1.176 2021/03/17 15:45:30 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
|
||||
|
@ -35,7 +35,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: cgram.y,v 1.175 2021/03/17 01:53:21 rillig Exp $");
|
||||
__RCSID("$NetBSD: cgram.y,v 1.176 2021/03/17 15:45:30 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
@ -107,7 +107,7 @@ RESTORE_WARN_FLAGS(const char *file, size_t line)
|
|||
#define SAVE_WARN_FLAGS(f, l) olwarn = lwarn
|
||||
#define RESTORE_WARN_FLAGS(f, l) \
|
||||
(void)(olwarn == LWARN_BAD ? (clear_warn_flags(), 0) : (lwarn = olwarn))
|
||||
#define cgram_debug(fmt, args...) (void)0
|
||||
#define cgram_debug(fmt, args...) do { } while (false)
|
||||
#endif
|
||||
|
||||
/* unbind the anonymous struct members from the struct */
|
||||
|
@ -1359,6 +1359,7 @@ range:
|
|||
|
||||
designator: /* C99 6.7.8 "Initialization" */
|
||||
T_LBRACK range T_RBRACK {
|
||||
designator_push_subscript($2);
|
||||
if (!Sflag)
|
||||
/* array initializer with des.s is a C9X feature */
|
||||
warning(321);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: externs1.h,v 1.75 2021/03/17 01:53:21 rillig Exp $ */
|
||||
/* $NetBSD: externs1.h,v 1.76 2021/03/17 15:45:30 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
|
@ -300,6 +300,7 @@ extern void init_rbrace(void);
|
|||
extern void init_lbrace(void);
|
||||
extern void init_using_expr(tnode_t *);
|
||||
extern void push_member(sbuf_t *);
|
||||
extern void designator_push_subscript(range_t);
|
||||
|
||||
/*
|
||||
* emit.c
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: init.c,v 1.90 2021/03/17 15:37:42 rillig Exp $ */
|
||||
/* $NetBSD: init.c,v 1.91 2021/03/17 15:45:30 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1994, 1995 Jochen Pohl
|
||||
|
@ -37,7 +37,7 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(__RCSID) && !defined(lint)
|
||||
__RCSID("$NetBSD: init.c,v 1.90 2021/03/17 15:37:42 rillig Exp $");
|
||||
__RCSID("$NetBSD: init.c,v 1.91 2021/03/17 15:45:30 rillig Exp $");
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -287,6 +287,22 @@ push_member(sbuf_t *sb)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* A struct member that has array type is initialized using a designator.
|
||||
*
|
||||
* C99 example: struct { int member[4]; } var = { [2] = 12345 };
|
||||
*
|
||||
* GNU example: struct { int member[4]; } var = { [1 ... 3] = 12345 };
|
||||
*/
|
||||
void
|
||||
designator_push_subscript(range_t range)
|
||||
{
|
||||
debug_enter();
|
||||
debug_step("subscript range is %zu ... %zu", range.lo, range.hi);
|
||||
debug_initstack();
|
||||
debug_leave();
|
||||
}
|
||||
|
||||
static void
|
||||
pop_member(void)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue