From 6892362adf4c6d4f5e47f3cb470105c29e1bed98 Mon Sep 17 00:00:00 2001 From: christos Date: Fri, 1 May 2009 22:03:36 +0000 Subject: [PATCH] add variable declarations in for loops for c99 --- usr.bin/xlint/lint1/Makefile | 3 ++- usr.bin/xlint/lint1/cgram.y | 14 ++++++++++---- usr.bin/xlint/lint1/err.c | 5 +++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/usr.bin/xlint/lint1/Makefile b/usr.bin/xlint/lint1/Makefile index 198837148b7e..dcacfb6b2431 100644 --- a/usr.bin/xlint/lint1/Makefile +++ b/usr.bin/xlint/lint1/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.42 2009/04/14 09:10:00 lukem Exp $ +# $NetBSD: Makefile,v 1.43 2009/05/01 22:03:36 christos Exp $ .include @@ -8,6 +8,7 @@ SRCS= cgram.y scan.l mem1.c mem.c err.c main1.c decl.c tree.c func.c \ MAN= lint.7 YHEADER= #CFLAGS+=-g +#CPPFLAGS+=-DYYDEBUG=1 CPPFLAGS+= -I${.CURDIR} -I. -DPASS=\"${PROG}.h\" diff --git a/usr.bin/xlint/lint1/cgram.y b/usr.bin/xlint/lint1/cgram.y index 47ade2c09e75..139d4e158cf6 100644 --- a/usr.bin/xlint/lint1/cgram.y +++ b/usr.bin/xlint/lint1/cgram.y @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.42 2008/11/16 07:06:37 dholland Exp $ */ +/* $NetBSD: cgram.y,v 1.43 2009/05/01 22:03:36 christos Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.42 2008/11/16 07:06:37 dholland Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.43 2009/05/01 22:03:36 christos Exp $"); #endif #include @@ -107,7 +107,7 @@ static inline void RESTORE(const char *file, size_t line) #endif %} -%expect 1 +%expect 3 %union { int y_int; @@ -1462,7 +1462,13 @@ do_while_expr: ; for_exprs: - T_FOR T_LPARN opt_expr T_SEMI opt_expr T_SEMI opt_expr T_RPARN { + T_FOR T_LPARN declspecs deftyp notype_init_decls T_SEMI opt_expr + T_SEMI opt_expr T_RPARN { + c99ism(325); + for1(NULL, $7, $9); + CLRWFLGS(__FILE__, __LINE__); + } + | T_FOR T_LPARN opt_expr T_SEMI opt_expr T_SEMI opt_expr T_RPARN { for1($3, $5, $7); CLRWFLGS(__FILE__, __LINE__); } diff --git a/usr.bin/xlint/lint1/err.c b/usr.bin/xlint/lint1/err.c index e2597d6d569d..0d25b3e58aba 100644 --- a/usr.bin/xlint/lint1/err.c +++ b/usr.bin/xlint/lint1/err.c @@ -1,4 +1,4 @@ -/* $NetBSD: err.c,v 1.40 2009/04/15 01:20:57 christos Exp $ */ +/* $NetBSD: err.c,v 1.41 2009/05/01 22:03:36 christos Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: err.c,v 1.40 2009/04/15 01:20:57 christos Exp $"); +__RCSID("$NetBSD: err.c,v 1.41 2009/05/01 22:03:36 christos Exp $"); #endif #include @@ -384,6 +384,7 @@ const char *msgs[] = { "zero sized array is a C99 extension", /* 322 */ "continue in 'do ... while (0)' loop", /* 323 */ "suggest cast from '%s' to '%s' on op %s to avoid overflow", /* 324 */ + "variable declaration in for loop", /* 325 */ }; /*