diff options
author | Chad Loder <cloder@cvs.openbsd.org> | 2005-11-23 18:47:42 +0000 |
---|---|---|
committer | Chad Loder <cloder@cvs.openbsd.org> | 2005-11-23 18:47:42 +0000 |
commit | d66b8e9d75a34c932adf952c227220b082f408e4 (patch) | |
tree | 70e845275fb34ab17922b506eb06d03e9aaf55bb /usr.bin/xlint/lint1 | |
parent | 7125bfd190c8e24a78c0f9112f6d087f506837ec (diff) |
Grok __restrict__ and __restrict keywords. OK deraadt
Diffstat (limited to 'usr.bin/xlint/lint1')
-rw-r--r-- | usr.bin/xlint/lint1/cgram.y | 6 | ||||
-rw-r--r-- | usr.bin/xlint/lint1/decl.c | 23 | ||||
-rw-r--r-- | usr.bin/xlint/lint1/lint1.h | 7 | ||||
-rw-r--r-- | usr.bin/xlint/lint1/scan.l | 6 |
4 files changed, 28 insertions, 14 deletions
diff --git a/usr.bin/xlint/lint1/cgram.y b/usr.bin/xlint/lint1/cgram.y index 001591dc300..9d5e14746b6 100644 --- a/usr.bin/xlint/lint1/cgram.y +++ b/usr.bin/xlint/lint1/cgram.y @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: cgram.y,v 1.7 2005/11/23 09:05:42 deraadt Exp $ */ +/* $OpenBSD: cgram.y,v 1.8 2005/11/23 18:47:40 cloder Exp $ */ /* $NetBSD: cgram.y,v 1.8 1995/10/02 17:31:35 jpo Exp $ */ /* @@ -34,7 +34,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: cgram.y,v 1.7 2005/11/23 09:05:42 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: cgram.y,v 1.8 2005/11/23 18:47:40 cloder Exp $"; #endif #include <stdlib.h> @@ -107,7 +107,7 @@ static void ignuptorp(void); /* types (char, int, short, long, unsigned, signed, float, double, void) */ %token <y_tspec> T_TYPE -/* qualifiers (const, volatile) */ +/* qualifiers (const, volatile, restrict) */ %token <y_tqual> T_QUAL /* struct or union */ diff --git a/usr.bin/xlint/lint1/decl.c b/usr.bin/xlint/lint1/decl.c index 7de8165be3e..8d4951d8f1e 100644 --- a/usr.bin/xlint/lint1/decl.c +++ b/usr.bin/xlint/lint1/decl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: decl.c,v 1.14 2005/11/20 18:18:57 cloder Exp $ */ +/* $OpenBSD: decl.c,v 1.15 2005/11/23 18:47:41 cloder Exp $ */ /* $NetBSD: decl.c,v 1.11 1995/10/02 17:34:16 jpo Exp $ */ /* @@ -33,7 +33,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: decl.c,v 1.14 2005/11/20 18:18:57 cloder Exp $"; +static char rcsid[] = "$OpenBSD: decl.c,v 1.15 2005/11/23 18:47:41 cloder Exp $"; #endif #include <sys/param.h> @@ -518,15 +518,20 @@ addqual(tqual_t q) warning(10, "const"); } dcs->d_const = 1; - } else { - if (q != VOLATILE) - lerror("addqual() 1"); + } else if (q == VOLATILE) { if (dcs->d_volatile) { /* duplicate "%s" */ warning(10, "volatile"); } dcs->d_volatile = 1; - } + } else if (q == RESTRICT) { + if (dcs->d_restrict) { + /* duplicate "%s" */ + warning(10, "restrict"); + } + dcs->d_restrict = 1; + } else + lerror("addqual() 1"); } /* @@ -984,10 +989,11 @@ chktyp(sym_t *sym) } } if (t == VOID && to != PTR) { - if (tp->t_const || tp->t_volatile) { + if (tp->t_const || tp->t_volatile || tp->t_restrict) { /* inappropriate qualifiers with "void" */ warning(69); tp->t_const = tp->t_volatile = 0; + tp->t_restrict = 0; } } tpp = &tp->t_subt; @@ -1987,6 +1993,9 @@ eqtype(type_t *tp1, type_t *tp2, int ignqual, int promot, int *warn) if (tp1->t_volatile != tp2->t_volatile && !ignqual && !tflag) return (0); + if (tp1->t_restrict != tp2->t_restrict && !ignqual && !tflag) + return (0); + if (t == STRUCT || t == UNION) return (tp1->t_str == tp2->t_str); diff --git a/usr.bin/xlint/lint1/lint1.h b/usr.bin/xlint/lint1/lint1.h index cc90d5e6c00..c57a75a6f08 100644 --- a/usr.bin/xlint/lint1/lint1.h +++ b/usr.bin/xlint/lint1/lint1.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lint1.h,v 1.3 2005/11/20 17:42:49 deraadt Exp $ */ +/* $OpenBSD: lint1.h,v 1.4 2005/11/23 18:47:41 cloder Exp $ */ /* $NetBSD: lint1.h,v 1.6 1995/10/02 17:31:41 jpo Exp $ */ /* @@ -66,7 +66,7 @@ typedef struct strg { * qualifiers (only for lex/yacc interface) */ typedef enum { - CONST, VOLATILE + CONST, VOLATILE, RESTRICT } tqual_t; /* @@ -123,6 +123,7 @@ typedef struct type { u_int t_aincompl : 1; /* incomplete array type */ u_int t_const : 1; /* const modifier */ u_int t_volatile : 1; /* volatile modifier */ + u_int t_restrict : 1; /* restrict modifier */ u_int t_proto : 1; /* function prototype (t_args valid) */ u_int t_vararg : 1; /* protoype with ... */ u_int t_typedef : 1; /* type defined with typedef */ @@ -303,6 +304,7 @@ typedef struct dinfo { scl_t d_ctx; /* context of declaration */ u_int d_const : 1; /* const in declaration specifiers */ u_int d_volatile : 1; /* volatile in declaration specifiers */ + u_int d_restrict : 1; /* restrict in declaration specifiers */ u_int d_inline : 1; /* inline in declaration specifiers */ u_int d_mscl : 1; /* multiple storage classes */ u_int d_terr : 1; /* invalid type combination */ @@ -342,6 +344,7 @@ typedef struct pqinf { int p_pcnt; /* number of asterisks */ u_int p_const : 1; u_int p_volatile : 1; + u_int p_restrict : 1; struct pqinf *p_nxt; } pqinf_t; diff --git a/usr.bin/xlint/lint1/scan.l b/usr.bin/xlint/lint1/scan.l index 7fd6be53c60..a122444cf38 100644 --- a/usr.bin/xlint/lint1/scan.l +++ b/usr.bin/xlint/lint1/scan.l @@ -1,5 +1,5 @@ %{ -/* $OpenBSD: scan.l,v 1.9 2005/11/23 09:05:42 deraadt Exp $ */ +/* $OpenBSD: scan.l,v 1.10 2005/11/23 18:47:41 cloder Exp $ */ /* $NetBSD: scan.l,v 1.8 1995/10/23 13:38:51 jpo Exp $ */ /* @@ -34,7 +34,7 @@ */ #ifndef lint -static char rcsid[] = "$OpenBSD: scan.l,v 1.9 2005/11/23 09:05:42 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: scan.l,v 1.10 2005/11/23 18:47:41 cloder Exp $"; #endif #include <stdlib.h> @@ -217,6 +217,8 @@ static struct kwtab { { "int", T_TYPE, 0, INT, 0, 0, 0 }, { "long", T_TYPE, 0, LONG, 0, 0, 0 }, { "register", T_SCLASS, REG, 0, 0, 0, 0 }, + { "__restrict", T_QUAL, 0, 0, RESTRICT, 0, 0 }, + { "__restrict__", T_QUAL, 0, 0, RESTRICT, 0, 0 }, { "return", T_RETURN, 0, 0, 0, 0, 0 }, { "short", T_TYPE, 0, SHORT, 0, 0, 0 }, { "signed", T_TYPE, 0, SIGNED, 0, 1, 0 }, |