Wed Dec 10 16:12:39 2008 UTC ()
Ignore restrict in the contexts where const and volatile is allowed.
No validation for the use (e.g. that it is used on a pointer), but
enough to not stop valid C99 programs.


(joerg)
diff -r1.21 -r1.22 src/usr.bin/xlint/lint1/lint1.h
diff -r1.41 -r1.42 src/usr.bin/xlint/lint1/scan.l

cvs diff -r1.21 -r1.22 src/usr.bin/xlint/lint1/lint1.h (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/lint1.h 2008/05/01 21:52:19 1.21
+++ src/usr.bin/xlint/lint1/lint1.h 2008/12/10 16:12:39 1.22
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lint1.h,v 1.21 2008/05/01 21:52:19 christos Exp $ */ 1/* $NetBSD: lint1.h,v 1.22 2008/12/10 16:12:39 joerg Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. 4 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
5 * Copyright (c) 1994, 1995 Jochen Pohl 5 * Copyright (c) 1994, 1995 Jochen Pohl
6 * All Rights Reserved. 6 * All Rights Reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -71,27 +71,27 @@ typedef struct strg { @@ -71,27 +71,27 @@ typedef struct strg {
71 union { 71 union {
72 u_char *_st_cp; 72 u_char *_st_cp;
73 wchar_t *_st_wcp; 73 wchar_t *_st_wcp;
74 } st_u; 74 } st_u;
75} strg_t; 75} strg_t;
76 76
77#define st_cp st_u._st_cp 77#define st_cp st_u._st_cp
78#define st_wcp st_u._st_wcp 78#define st_wcp st_u._st_wcp
79 79
80/* 80/*
81 * qualifiers (only for lex/yacc interface) 81 * qualifiers (only for lex/yacc interface)
82 */ 82 */
83typedef enum { 83typedef enum {
84 CONST, VOLATILE 84 CONST, VOLATILE, RESTRICT
85} tqual_t; 85} tqual_t;
86 86
87/* 87/*
88 * Integer and floating point values are stored in this structure 88 * Integer and floating point values are stored in this structure
89 */ 89 */
90typedef struct { 90typedef struct {
91 tspec_t v_tspec; 91 tspec_t v_tspec;
92 int v_ansiu; /* set if an integer constant is 92 int v_ansiu; /* set if an integer constant is
93 unsigned in ANSI C */ 93 unsigned in ANSI C */
94 union { 94 union {
95 int64_t _v_quad; /* integers */ 95 int64_t _v_quad; /* integers */
96 ldbl_t _v_ldbl; /* floats */ 96 ldbl_t _v_ldbl; /* floats */
97 } v_u; 97 } v_u;

cvs diff -r1.41 -r1.42 src/usr.bin/xlint/lint1/scan.l (expand / switch to unified diff)

--- src/usr.bin/xlint/lint1/scan.l 2008/10/13 14:00:37 1.41
+++ src/usr.bin/xlint/lint1/scan.l 2008/12/10 16:12:39 1.42
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1%{ 1%{
2/* $NetBSD: scan.l,v 1.41 2008/10/13 14:00:37 dholland Exp $ */ 2/* $NetBSD: scan.l,v 1.42 2008/12/10 16:12:39 joerg Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. 5 * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved.
6 * Copyright (c) 1994, 1995 Jochen Pohl 6 * Copyright (c) 1994, 1995 Jochen Pohl
7 * All Rights Reserved. 7 * All Rights Reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the 15 * notice, this list of conditions and the following disclaimer in the
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 25 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 26 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 27 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37#if defined(__RCSID) && !defined(lint) 37#if defined(__RCSID) && !defined(lint)
38__RCSID("$NetBSD: scan.l,v 1.41 2008/10/13 14:00:37 dholland Exp $"); 38__RCSID("$NetBSD: scan.l,v 1.42 2008/12/10 16:12:39 joerg Exp $");
39#endif 39#endif
40 40
41#include <stdlib.h> 41#include <stdlib.h>
42#include <string.h> 42#include <string.h>
43#include <limits.h> 43#include <limits.h>
44#include <float.h> 44#include <float.h>
45#include <ctype.h> 45#include <ctype.h>
46#include <errno.h> 46#include <errno.h>
47#include <math.h> 47#include <math.h>
48 48
49#include "lint1.h" 49#include "lint1.h"
50#include "cgram.h" 50#include "cgram.h"
51 51
@@ -215,26 +215,27 @@ static struct kwtab { @@ -215,26 +215,27 @@ static struct kwtab {
215 { "float", T_TYPE, 0, FLOAT, 0, 0, 0, 0 }, 215 { "float", T_TYPE, 0, FLOAT, 0, 0, 0, 0 },
216 { "for", T_FOR, 0, 0, 0, 0, 0, 0 }, 216 { "for", T_FOR, 0, 0, 0, 0, 0, 0 },
217 { "goto", T_GOTO, 0, 0, 0, 0, 0, 0 }, 217 { "goto", T_GOTO, 0, 0, 0, 0, 0, 0 },
218 { "if", T_IF, 0, 0, 0, 0, 0, 0 }, 218 { "if", T_IF, 0, 0, 0, 0, 0, 0 },
219 { "__imag__", T_IMAG, 0, 0, 0, 0, 1, 0 }, 219 { "__imag__", T_IMAG, 0, 0, 0, 0, 1, 0 },
220 { "inline", T_SCLASS, INLINE, 0, 0, 0, 1, 0 }, 220 { "inline", T_SCLASS, INLINE, 0, 0, 0, 1, 0 },
221 { "__inline__", T_SCLASS, INLINE, 0, 0, 0, 0, 0 }, 221 { "__inline__", T_SCLASS, INLINE, 0, 0, 0, 0, 0 },
222 { "__inline", T_SCLASS, INLINE, 0, 0, 0, 0, 0 }, 222 { "__inline", T_SCLASS, INLINE, 0, 0, 0, 0, 0 },
223 { "int", T_TYPE, 0, INT, 0, 0, 0, 0 }, 223 { "int", T_TYPE, 0, INT, 0, 0, 0, 0 },
224 { "__symbolrename", T_SYMBOLRENAME, 0, 0, 0, 0, 0, 0 }, 224 { "__symbolrename", T_SYMBOLRENAME, 0, 0, 0, 0, 0, 0 },
225 { "long", T_TYPE, 0, LONG, 0, 0, 0, 0 }, 225 { "long", T_TYPE, 0, LONG, 0, 0, 0, 0 },
226 { "__real__", T_REAL, 0, 0, 0, 0, 1, 0 }, 226 { "__real__", T_REAL, 0, 0, 0, 0, 1, 0 },
227 { "register", T_SCLASS, REG, 0, 0, 0, 0, 0 }, 227 { "register", T_SCLASS, REG, 0, 0, 0, 0, 0 },
 228 { "restrict", T_QUAL, 0, 0, RESTRICT, 0, 1, 0 },
228 { "return", T_RETURN, 0, 0, 0, 0, 0, 0 }, 229 { "return", T_RETURN, 0, 0, 0, 0, 0, 0 },
229 { "short", T_TYPE, 0, SHORT, 0, 0, 0, 0 }, 230 { "short", T_TYPE, 0, SHORT, 0, 0, 0, 0 },
230 { "signed", T_TYPE, 0, SIGNED, 0, 1, 0, 0 }, 231 { "signed", T_TYPE, 0, SIGNED, 0, 1, 0, 0 },
231 { "__signed__", T_TYPE, 0, SIGNED, 0, 0, 0, 0 }, 232 { "__signed__", T_TYPE, 0, SIGNED, 0, 0, 0, 0 },
232 { "__signed", T_TYPE, 0, SIGNED, 0, 0, 0, 0 }, 233 { "__signed", T_TYPE, 0, SIGNED, 0, 0, 0, 0 },
233 { "sizeof", T_SIZEOF, 0, 0, 0, 0, 0, 0 }, 234 { "sizeof", T_SIZEOF, 0, 0, 0, 0, 0, 0 },
234 { "static", T_SCLASS, STATIC, 0, 0, 0, 0, 0 }, 235 { "static", T_SCLASS, STATIC, 0, 0, 0, 0, 0 },
235 { "struct", T_SOU, 0, STRUCT, 0, 0, 0, 0 }, 236 { "struct", T_SOU, 0, STRUCT, 0, 0, 0, 0 },
236 { "switch", T_SWITCH, 0, 0, 0, 0, 0, 0 }, 237 { "switch", T_SWITCH, 0, 0, 0, 0, 0, 0 },
237 { "typedef", T_SCLASS, TYPEDEF, 0, 0, 0, 0, 0 }, 238 { "typedef", T_SCLASS, TYPEDEF, 0, 0, 0, 0, 0 },
238 { "union", T_SOU, 0, UNION, 0, 0, 0, 0 }, 239 { "union", T_SOU, 0, UNION, 0, 0, 0, 0 },
239 { "unsigned", T_TYPE, 0, UNSIGN, 0, 0, 0, 0 }, 240 { "unsigned", T_TYPE, 0, UNSIGN, 0, 0, 0, 0 },
240 { "void", T_TYPE, 0, VOID, 0, 0, 0, 0 }, 241 { "void", T_TYPE, 0, VOID, 0, 0, 0, 0 },