Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/xlint/lint1 handle anonymous struct/union members.
details: https://anonhg.NetBSD.org/src/rev/99d088aea7fa
branches: trunk
changeset: 340993:99d088aea7fa
user: christos <christos%NetBSD.org@localhost>
date: Tue Oct 13 20:25:21 2015 +0000
description:
handle anonymous struct/union members.
diffstat:
usr.bin/xlint/lint1/cgram.y | 28 ++++++++++++++++++++++------
usr.bin/xlint/lint1/decl.c | 7 +++++--
2 files changed, 27 insertions(+), 8 deletions(-)
diffs (89 lines):
diff -r fd7cb0399ef9 -r 99d088aea7fa usr.bin/xlint/lint1/cgram.y
--- a/usr.bin/xlint/lint1/cgram.y Tue Oct 13 20:12:03 2015 +0000
+++ b/usr.bin/xlint/lint1/cgram.y Tue Oct 13 20:25:21 2015 +0000
@@ -1,5 +1,5 @@
%{
-/* $NetBSD: cgram.y,v 1.72 2015/10/13 16:09:33 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.73 2015/10/13 20:25:21 christos 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.72 2015/10/13 16:09:33 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.73 2015/10/13 20:25:21 christos Exp $");
#endif
#include <stdlib.h>
@@ -105,6 +105,14 @@
#define SAVE(f, l) olwarn = lwarn
#define RESTORE(f, l) (void)(olwarn == LWARN_BAD ? (clrwflgs(), 0) : (lwarn = olwarn))
#endif
+
+/* unbind the anonymous struct members from the struct */
+static void
+anonymize(sym_t *s)
+{
+ for ( ; s; s = s->s_nxt)
+ s->s_styp = NULL;
+}
%}
%expect 80
@@ -698,14 +706,22 @@
$$ = $4;
}
| noclass_declmods deftyp {
+ symtyp = FMOS;
/* struct or union member must be named */
- warning(49);
- $$ = NULL;
+ if (!Sflag)
+ warning(49);
+ /* add all the members of the anonymous struct/union */
+ $$ = dcs->d_type->t_str->memb;
+ anonymize($$);
}
| noclass_declspecs deftyp {
+ symtyp = FMOS;
/* struct or union member must be named */
- warning(49);
- $$ = NULL;
+ if (!Sflag)
+ warning(49);
+ $$ = dcs->d_type->t_str->memb;
+ /* add all the members of the anonymous struct/union */
+ anonymize($$);
}
| error {
symtyp = FVFT;
diff -r fd7cb0399ef9 -r 99d088aea7fa usr.bin/xlint/lint1/decl.c
--- a/usr.bin/xlint/lint1/decl.c Tue Oct 13 20:12:03 2015 +0000
+++ b/usr.bin/xlint/lint1/decl.c Tue Oct 13 20:25:21 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.59 2014/04/18 00:20:37 christos Exp $ */
+/* $NetBSD: decl.c,v 1.60 2015/10/13 20:25:21 christos Exp $ */
/*
* Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
@@ -38,7 +38,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: decl.c,v 1.59 2014/04/18 00:20:37 christos Exp $");
+__RCSID("$NetBSD: decl.c,v 1.60 2015/10/13 20:25:21 christos Exp $");
#endif
#include <sys/param.h>
@@ -1778,6 +1778,9 @@
} else {
n = 0;
for (mem = fmem; mem != NULL; mem = mem->s_nxt) {
+ /* bind anonymous members to the structure */
+ if (mem->s_styp == NULL)
+ mem->s_styp = sp;
if (mem->s_name != unnamed)
n++;
}
Home |
Main Index |
Thread Index |
Old Index