Module Name: src Committed By: christos Date: Tue Dec 14 20:13:13 UTC 2021
Modified Files: src/usr.bin/xlint/lint1: cgram.y lex.c Log Message: Improve restrict handling. To generate a diff of this commit: cvs rdiff -u -r1.372 -r1.373 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.88 -r1.89 src/usr.bin/xlint/lint1/lex.c 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.372 src/usr.bin/xlint/lint1/cgram.y:1.373 --- src/usr.bin/xlint/lint1/cgram.y:1.372 Sun Nov 28 04:59:59 2021 +++ src/usr.bin/xlint/lint1/cgram.y Tue Dec 14 15:13:13 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.372 2021/11/28 09:59:59 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.373 2021/12/14 20:13:13 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.372 2021/11/28 09:59:59 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.373 2021/12/14 20:13:13 christos Exp $"); #endif #include <limits.h> @@ -1357,7 +1357,7 @@ array_size_opt: } | array_size { $$.has_dim = true; - $$.dim = to_int_constant($1, false); + $$.dim = $1 == NULL ? 0 : to_int_constant($1, false); } ; @@ -1370,6 +1370,12 @@ array_size: c11ism(343); $$ = $3; } + | T_QUAL { + /* C11, 6.7.6.2 */ + if ($1 != RESTRICT) + yyerror("Bad attribute"); + $$ = NULL; + } | constant_expr ; Index: src/usr.bin/xlint/lint1/lex.c diff -u src/usr.bin/xlint/lint1/lex.c:1.88 src/usr.bin/xlint/lint1/lex.c:1.89 --- src/usr.bin/xlint/lint1/lex.c:1.88 Sat Nov 27 15:13:48 2021 +++ src/usr.bin/xlint/lint1/lex.c Tue Dec 14 15:13:13 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.88 2021/11/27 20:13:48 christos Exp $ */ +/* $NetBSD: lex.c,v 1.89 2021/12/14 20:13:13 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: lex.c,v 1.88 2021/11/27 20:13:48 christos Exp $"); +__RCSID("$NetBSD: lex.c,v 1.89 2021/12/14 20:13:13 christos Exp $"); #endif #include <ctype.h> @@ -205,7 +205,7 @@ static struct kwtab { kwdef_token( "__real__", T_REAL, 0,0,1,0,1), kwdef_sclass( "register", REG, 0,0,0,0,1), kwdef_gcc_attr( "regparm", T_AT_REGPARM), - kwdef_tqual( "restrict", RESTRICT, 0,1,0,0,5), + kwdef_tqual( "restrict", RESTRICT, 0,1,0,0,7), kwdef_keyword( "return", T_RETURN), kwdef_gcc_attr( "returns_nonnull",T_AT_RETURNS_NONNULL), kwdef_gcc_attr( "returns_twice",T_AT_RETURNS_TWICE),