Module Name:    src
Committed By:   christos
Date:           Tue Dec 27 21:52:36 UTC 2016

Modified Files:
        src/usr.bin/xlint/lint1: cgram.y decl.c externs1.h lint1.h

Log Message:
teach lint __attribute__((__unused__))


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/usr.bin/xlint/lint1/cgram.y
cvs rdiff -u -r1.66 -r1.67 src/usr.bin/xlint/lint1/decl.c
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/xlint/lint1/externs1.h
cvs rdiff -u -r1.29 -r1.30 src/usr.bin/xlint/lint1/lint1.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.81 src/usr.bin/xlint/lint1/cgram.y:1.82
--- src/usr.bin/xlint/lint1/cgram.y:1.81	Fri Nov  4 21:09:30 2016
+++ src/usr.bin/xlint/lint1/cgram.y	Tue Dec 27 16:52:35 2016
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.81 2016/11/05 01:09:30 christos Exp $ */
+/* $NetBSD: cgram.y,v 1.82 2016/12/27 21:52:35 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.81 2016/11/05 01:09:30 christos Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.82 2016/12/27 21:52:35 christos Exp $");
 #endif
 
 #include <stdlib.h>
@@ -516,7 +516,9 @@ type_attribute_spec:
 	| T_AT_GNU_INLINE
 	| T_AT_FORMAT T_LPARN type_attribute_format_type T_COMMA
 	    constant T_COMMA constant T_RPARN
-	| T_AT_UNUSED
+	| T_AT_UNUSED {
+		addused();
+	}
 	| T_AT_WEAK
 	| T_AT_VISIBILITY T_LPARN constant T_RPARN
 	| T_QUAL {

Index: src/usr.bin/xlint/lint1/decl.c
diff -u src/usr.bin/xlint/lint1/decl.c:1.66 src/usr.bin/xlint/lint1/decl.c:1.67
--- src/usr.bin/xlint/lint1/decl.c:1.66	Thu Nov  3 18:08:30 2016
+++ src/usr.bin/xlint/lint1/decl.c	Tue Dec 27 16:52:35 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: decl.c,v 1.66 2016/11/03 22:08:30 kamil Exp $ */
+/* $NetBSD: decl.c,v 1.67 2016/12/27 21:52:35 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.66 2016/11/03 22:08:30 kamil Exp $");
+__RCSID("$NetBSD: decl.c,v 1.67 2016/12/27 21:52:35 christos Exp $");
 #endif
 
 #include <sys/param.h>
@@ -537,6 +537,12 @@ addpacked(void)
 		setpackedsize(dcs->d_type);
 }
 
+void
+addused(void)
+{
+	dcs->d_used = 1;
+}
+
 /*
  * Remember a qualifier which is part of the declaration specifiers
  * (and not the declarator) in the top element of the declaration stack.
@@ -2365,6 +2371,7 @@ decl1arg(sym_t *sym, int initflg)
 	if (sym->s_type->t_tspec != VOID)
 		(void)length(sym->s_type, sym->s_name);
 
+	sym->s_used = dcs->d_used;
 	setsflg(sym);
 
 	return (sym);

Index: src/usr.bin/xlint/lint1/externs1.h
diff -u src/usr.bin/xlint/lint1/externs1.h:1.33 src/usr.bin/xlint/lint1/externs1.h:1.34
--- src/usr.bin/xlint/lint1/externs1.h:1.33	Sat Dec 24 12:43:45 2016
+++ src/usr.bin/xlint/lint1/externs1.h	Tue Dec 27 16:52:35 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: externs1.h,v 1.33 2016/12/24 17:43:45 christos Exp $	*/
+/*	$NetBSD: externs1.h,v 1.34 2016/12/27 21:52:35 christos Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -145,6 +145,7 @@ extern	void	addscl(scl_t);
 extern	void	addtype(type_t *);
 extern	void	addqual(tqual_t);
 extern	void	addpacked(void);
+extern	void	addused(void);
 extern	void	pushdecl(scl_t);
 extern	void	popdecl(void);
 extern	void	setasm(void);

Index: src/usr.bin/xlint/lint1/lint1.h
diff -u src/usr.bin/xlint/lint1/lint1.h:1.29 src/usr.bin/xlint/lint1/lint1.h:1.30
--- src/usr.bin/xlint/lint1/lint1.h:1.29	Sun Jul 20 19:00:49 2014
+++ src/usr.bin/xlint/lint1/lint1.h	Tue Dec 27 16:52:35 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: lint1.h,v 1.29 2014/07/20 23:00:49 dholland Exp $ */
+/* $NetBSD: lint1.h,v 1.30 2016/12/27 21:52:35 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -344,6 +344,7 @@ typedef	struct dinfo {
 	u_int	d_notyp : 1;	/* set if no type specifier was present */
 	u_int	d_asm : 1;	/* set if d_ctx == AUTO and asm() present */
 	u_int	d_ispacked : 1;	/* packed */
+	u_int	d_used : 1;	/* used */
 	type_t	*d_tagtyp;	/* tag during member declaration */
 	sym_t	*d_fargs;	/* list of arguments during function def. */
 	pos_t	d_fdpos;	/* position of function definition */

Reply via email to