__{const,signed,volatile}{__,} added

const, signed and volatile are disabled with -t
This commit is contained in:
jpo 1995-10-02 17:18:53 +00:00
parent 2e332f67bf
commit ef83266200
4 changed files with 65 additions and 68 deletions

View File

@ -1,5 +1,5 @@
%{
/* $NetBSD: cgram.y,v 1.4 1995/10/02 17:14:06 jpo Exp $ */
/* $NetBSD: cgram.y,v 1.5 1995/10/02 17:18:53 jpo Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -33,7 +33,7 @@
*/
#ifndef lint
static char rcsid[] = "$NetBSD: cgram.y,v 1.4 1995/10/02 17:14:06 jpo Exp $";
static char rcsid[] = "$NetBSD: cgram.y,v 1.5 1995/10/02 17:18:53 jpo Exp $";
#endif
#include <stdlib.h>
@ -933,15 +933,10 @@ type_qualifier_list:
type_qualifier:
T_QUAL {
$$ = xcalloc(1, sizeof (pqinf_t));
if (tflag) {
/* const and volatile illegal in traditional C */
warning(269);
if ($1 == CONST) {
$$->p_const = 1;
} else {
if ($1 == CONST) {
$$->p_const = 1;
} else {
$$->p_volatile = 1;
}
$$->p_volatile = 1;
}
}
;

View File

@ -1,4 +1,4 @@
/* $NetBSD: decl.c,v 1.4 1995/10/02 17:14:11 jpo Exp $ */
/* $NetBSD: decl.c,v 1.5 1995/10/02 17:18:57 jpo Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -32,7 +32,7 @@
*/
#ifndef lint
static char rcsid[] = "$NetBSD: decl.c,v 1.4 1995/10/02 17:14:11 jpo Exp $";
static char rcsid[] = "$NetBSD: decl.c,v 1.5 1995/10/02 17:18:57 jpo Exp $";
#endif
#include <sys/param.h>
@ -345,10 +345,6 @@ addtype(tp)
}
dcs->d_type = tp;
return;
} else {
if (tflag && tp->t_tspec == SIGNED)
/* 'signed' is illegal in traditional C */
warning(265);
}
t = tp->t_tspec;
@ -527,12 +523,6 @@ void
addqual(q)
tqual_t q;
{
if (tflag) {
/* const and volatile are illegal in traditional C */
warning(269);
return;
}
if (q == CONST) {
if (dcs->d_const) {
/* duplicate "%s" */
@ -1801,7 +1791,7 @@ decl1ext(dsym, initflg)
dsym->s_inline = 1;
} else {
/* variable declared inline: %s */
warning(310, dsym->s_name);
warning(268, dsym->s_name);
}
}
@ -2282,7 +2272,7 @@ decl1arg(sym, initflg)
if (dcs->d_inline)
/* argument declared inline: %s */
warning(311, sym->s_name);
warning(269, sym->s_name);
/*
* Arguments must have complete types. lengths() prints the needed
@ -2489,7 +2479,7 @@ decl1loc(dsym, initflg)
dsym->s_inline = 1;
} else {
/* variable declared inline: %s */
warning(310, dsym->s_name);
warning(268, dsym->s_name);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: err.c,v 1.3 1995/10/02 17:14:17 jpo Exp $ */
/* $NetBSD: err.c,v 1.4 1995/10/02 17:19:01 jpo Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -32,7 +32,7 @@
*/
#ifndef lint
static char rcsid[] = "$NetBSD: err.c,v 1.3 1995/10/02 17:14:17 jpo Exp $";
static char rcsid[] = "$NetBSD: err.c,v 1.4 1995/10/02 17:19:01 jpo Exp $";
#endif
/* number of errors found */
@ -321,11 +321,11 @@ const char *msgs[] = {
"\\\" inside character constants undefined in traditional C", /* 262 */
"\\? undefined in traditional C", /* 263 */
"\\v undefined in traditional C", /* 264 */
"'signed' illegal in traditional C", /* 265 */
"", /* 265 */
"'long double' is illegal in traditional C", /* 266 */
"shift equal to size of object", /* 267 */
"", /* 268*/
"const and volatile are illegal in traditional C", /* 269 */
"variable declared inline: %s", /* 268 */
"argument declared inline: %s", /* 269 */
"function prototypes are illegal in traditional C", /* 270 */
"switch expression must be of type `int' in traditional C", /* 271 */
"empty translation unit", /* 272 */
@ -366,8 +366,6 @@ const char *msgs[] = {
"static variable %s set but not used", /* 307 */
"extra bits set to 1 in conversion of '%s' to '%s', op %s", /* 308 */
"extra bits set to 0 in conversion of '%s' to '%s', op %s", /* 309 */
"variable declared inline: %s", /* 310 */
"argument declared inline: %s", /* 311 */
};
/*

View File

@ -1,5 +1,5 @@
%{
/* $NetBSD: scan.l,v 1.4 1995/10/02 17:14:40 jpo Exp $ */
/* $NetBSD: scan.l,v 1.5 1995/10/02 17:19:03 jpo Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -33,7 +33,7 @@
*/
#ifndef lint
static char rcsid[] = "$NetBSD: scan.l,v 1.4 1995/10/02 17:14:40 jpo Exp $";
static char rcsid[] = "$NetBSD: scan.l,v 1.5 1995/10/02 17:19:03 jpo Exp $";
#endif
#include <stdlib.h>
@ -188,41 +188,51 @@ static struct kwtab {
scl_t kw_scl; /* storage class if kw_token T_SCLASS */
tspec_t kw_tspec; /* type spec. if kw_token T_TYPE or T_SOU */
tqual_t kw_tqual; /* type qual. fi kw_token T_QUAL */
u_int kw_stdc : 1; /* STDC keyword */
u_int kw_gcc : 1; /* GCC keyword */
} kwtab[] = {
{ "auto", T_SCLASS, AUTO, 0, 0 },
{ "break", T_BREAK, 0, 0, 0 },
{ "case", T_CASE, 0, 0, 0 },
{ "char", T_TYPE, 0, CHAR, 0 },
{ "const", T_QUAL, 0, 0, CONST },
{ "continue", T_CONTINUE, 0, 0, 0 },
{ "default", T_DEFAULT, 0, 0, 0 },
{ "do", T_DO, 0, 0, 0 },
{ "double", T_TYPE, 0, DOUBLE, 0 },
{ "else", T_ELSE, 0, 0, 0 },
{ "enum", T_ENUM, 0, 0, 0 },
{ "extern", T_SCLASS, EXTERN, 0, 0 },
{ "float", T_TYPE, 0, FLOAT, 0 },
{ "for", T_FOR, 0, 0, 0 },
{ "goto", T_GOTO, 0, 0, 0 },
{ "if", T_IF, 0, 0, 0 },
{ "inline", T_SCLASS, INLINE, 0, 0 },
{ "int", T_TYPE, 0, INT, 0 },
{ "long", T_TYPE, 0, LONG, 0 },
{ "register", T_SCLASS, REG, 0, 0 },
{ "return", T_RETURN, 0, 0, 0 },
{ "short", T_TYPE, 0, SHORT, 0 },
{ "signed", T_TYPE, 0, SIGNED, 0 },
{ "sizeof", T_SIZEOF, 0, 0, 0 },
{ "static", T_SCLASS, STATIC, 0, 0 },
{ "struct", T_SOU, 0, STRUCT, 0 },
{ "switch", T_SWITCH, 0, 0, 0 },
{ "typedef", T_SCLASS, TYPEDEF, 0, 0 },
{ "union", T_SOU, 0, UNION, 0 },
{ "unsigned", T_TYPE, 0, UNSIGN, 0 },
{ "void", T_TYPE, 0, VOID, 0 },
{ "volatile", T_QUAL, 0, 0, VOLATILE },
{ "while", T_WHILE, 0, 0, 0 },
{ NULL, 0, 0, 0, 0 }
{ "auto", T_SCLASS, AUTO, 0, 0, 0, 0 },
{ "break", T_BREAK, 0, 0, 0, 0, 0 },
{ "case", T_CASE, 0, 0, 0, 0, 0 },
{ "char", T_TYPE, 0, CHAR, 0, 0, 0 },
{ "const", T_QUAL, 0, 0, CONST, 1, 0 },
{ "__const__", T_QUAL, 0, 0, CONST, 0, 0 },
{ "__const", T_QUAL, 0, 0, CONST, 0, 0 },
{ "continue", T_CONTINUE, 0, 0, 0, 0, 0 },
{ "default", T_DEFAULT, 0, 0, 0, 0, 0 },
{ "do", T_DO, 0, 0, 0, 0, 0 },
{ "double", T_TYPE, 0, DOUBLE, 0, 0, 0 },
{ "else", T_ELSE, 0, 0, 0, 0, 0 },
{ "enum", T_ENUM, 0, 0, 0, 0, 0 },
{ "extern", T_SCLASS, EXTERN, 0, 0, 0, 0 },
{ "float", T_TYPE, 0, FLOAT, 0, 0, 0 },
{ "for", T_FOR, 0, 0, 0, 0, 0 },
{ "goto", T_GOTO, 0, 0, 0, 0, 0 },
{ "if", T_IF, 0, 0, 0, 0, 0 },
{ "inline", T_SCLASS, INLINE, 0, 0, 0, 1 },
{ "__inline__", T_SCLASS, INLINE, 0, 0, 0, 0 },
{ "__inline", T_SCLASS, INLINE, 0, 0, 0, 0 },
{ "int", T_TYPE, 0, INT, 0, 0, 0 },
{ "long", T_TYPE, 0, LONG, 0, 0, 0 },
{ "register", T_SCLASS, REG, 0, 0, 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 },
{ "__signed__", T_TYPE, 0, SIGNED, 0, 0, 0 },
{ "__signed", T_TYPE, 0, SIGNED, 0, 0, 0 },
{ "sizeof", T_SIZEOF, 0, 0, 0, 0, 0 },
{ "static", T_SCLASS, STATIC, 0, 0, 0, 0 },
{ "struct", T_SOU, 0, STRUCT, 0, 0, 0 },
{ "switch", T_SWITCH, 0, 0, 0, 0, 0 },
{ "typedef", T_SCLASS, TYPEDEF, 0, 0, 0, 0 },
{ "union", T_SOU, 0, UNION, 0, 0, 0 },
{ "unsigned", T_TYPE, 0, UNSIGN, 0, 0, 0 },
{ "void", T_TYPE, 0, VOID, 0, 0, 0 },
{ "volatile", T_QUAL, 0, 0, VOLATILE, 1, 0 },
{ "__volatile__", T_QUAL, 0, 0, VOLATILE, 0, 0 },
{ "__volatile", T_QUAL, 0, 0, VOLATILE, 0, 0 },
{ "while", T_WHILE, 0, 0, 0, 0, 0 },
{ NULL, 0, 0, 0, 0, 0, 0 }
};
/* Symbol table */
@ -257,6 +267,10 @@ initscan()
u_quad_t uq;
for (kw = kwtab; kw->kw_name != NULL; kw++) {
if (kw->kw_stdc && tflag)
continue;
if (kw->kw_gcc && !gflag)
continue;
sym = getblk(sizeof (sym_t));
sym->s_name = kw->kw_name;
sym->s_keyw = 1;