added inline keywords

"inline" is enabled by -g, "__inline" and "__inline__" are always available
This commit is contained in:
jpo 1995-10-02 17:14:06 +00:00
parent a5d55cc062
commit 2e332f67bf
10 changed files with 269 additions and 183 deletions

View File

@ -1,5 +1,5 @@
%{
/* $NetBSD: cgram.y,v 1.3 1995/10/02 17:08:31 jpo Exp $ */
/* $NetBSD: cgram.y,v 1.4 1995/10/02 17:14:06 jpo Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -33,7 +33,7 @@
*/
#ifndef lint
static char rcsid[] = "$NetBSD: cgram.y,v 1.3 1995/10/02 17:08:31 jpo Exp $";
static char rcsid[] = "$NetBSD: cgram.y,v 1.4 1995/10/02 17:14:06 jpo Exp $";
#endif
#include <stdlib.h>
@ -760,7 +760,7 @@ notype_init_decl:
| notype_decl {
idecl($1, 1);
} T_ASSIGN initializer {
chksz($1);
chksz($1);
}
;
@ -772,7 +772,7 @@ type_init_decl:
| type_decl {
idecl($1, 1);
} T_ASSIGN initializer {
chksz($1);
chksz($1);
}
;

View File

@ -1,4 +1,4 @@
/* $NetBSD: decl.c,v 1.3 1995/10/02 17:08:36 jpo Exp $ */
/* $NetBSD: decl.c,v 1.4 1995/10/02 17:14:11 jpo Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -32,7 +32,7 @@
*/
#ifndef lint
static char rcsid[] = "$NetBSD: decl.c,v 1.3 1995/10/02 17:08:36 jpo Exp $";
static char rcsid[] = "$NetBSD: decl.c,v 1.4 1995/10/02 17:14:11 jpo Exp $";
#endif
#include <sys/param.h>
@ -91,74 +91,74 @@ initdecl()
ttab_t it_ttab;
} ittab[] = {
{ SIGNED, { 0, 0,
SIGNED, UNSIGN,
0, 0, 0, 0, 0, "signed" } },
SIGNED, UNSIGN,
0, 0, 0, 0, 0, "signed" } },
{ UNSIGN, { 0, 0,
SIGNED, UNSIGN,
0, 0, 0, 0, 0, "unsigned" } },
SIGNED, UNSIGN,
0, 0, 0, 0, 0, "unsigned" } },
{ CHAR, { CHAR_BIT, CHAR_BIT,
SCHAR, UCHAR,
1, 0, 0, 1, 1, "char" } },
SCHAR, UCHAR,
1, 0, 0, 1, 1, "char" } },
{ SCHAR, { CHAR_BIT, CHAR_BIT,
SCHAR, UCHAR,
1, 0, 0, 1, 1, "signed char" } },
SCHAR, UCHAR,
1, 0, 0, 1, 1, "signed char" } },
{ UCHAR, { CHAR_BIT, CHAR_BIT,
SCHAR, UCHAR,
1, 1, 0, 1, 1, "unsigned char" } },
SCHAR, UCHAR,
1, 1, 0, 1, 1, "unsigned char" } },
{ SHORT, { sizeof (short) * CHAR_BIT, 2 * CHAR_BIT,
SHORT, USHORT,
1, 0, 0, 1, 1, "short" } },
SHORT, USHORT,
1, 0, 0, 1, 1, "short" } },
{ USHORT, { sizeof (u_short) * CHAR_BIT, 2 * CHAR_BIT,
SHORT, USHORT,
1, 1, 0, 1, 1, "unsigned short" } },
SHORT, USHORT,
1, 1, 0, 1, 1, "unsigned short" } },
{ INT, { sizeof (int) * CHAR_BIT, 3 * CHAR_BIT,
INT, UINT,
1, 0, 0, 1, 1, "int" } },
INT, UINT,
1, 0, 0, 1, 1, "int" } },
{ UINT, { sizeof (u_int) * CHAR_BIT, 3 * CHAR_BIT,
INT, UINT,
1, 1, 0, 1, 1, "unsigned int" } },
INT, UINT,
1, 1, 0, 1, 1, "unsigned int" } },
{ LONG, { sizeof (long) * CHAR_BIT, 4 * CHAR_BIT,
LONG, ULONG,
1, 0, 0, 1, 1, "long" } },
LONG, ULONG,
1, 0, 0, 1, 1, "long" } },
{ ULONG, { sizeof (u_long) * CHAR_BIT, 4 * CHAR_BIT,
LONG, ULONG,
1, 1, 0, 1, 1, "unsigned long" } },
LONG, ULONG,
1, 1, 0, 1, 1, "unsigned long" } },
{ QUAD, { sizeof (quad_t) * CHAR_BIT, 8 * CHAR_BIT,
QUAD, UQUAD,
1, 0, 0, 1, 1, "long long" } },
QUAD, UQUAD,
1, 0, 0, 1, 1, "long long" } },
{ UQUAD, { sizeof (u_quad_t) * CHAR_BIT, 8 * CHAR_BIT,
QUAD, UQUAD,
1, 1, 0, 1, 1, "unsigned long long" } },
QUAD, UQUAD,
1, 1, 0, 1, 1, "unsigned long long" } },
{ FLOAT, { sizeof (float) * CHAR_BIT, 4 * CHAR_BIT,
FLOAT, FLOAT,
0, 0, 1, 1, 1, "float" } },
FLOAT, FLOAT,
0, 0, 1, 1, 1, "float" } },
{ DOUBLE, { sizeof (double) * CHAR_BIT, 8 * CHAR_BIT,
DOUBLE, DOUBLE,
0, 0, 1, 1, 1, "double" } },
DOUBLE, DOUBLE,
0, 0, 1, 1, 1, "double" } },
{ LDOUBLE, { sizeof (ldbl_t) * CHAR_BIT, 10 * CHAR_BIT,
LDOUBLE, LDOUBLE,
0, 0, 1, 1, 1, "long double" } },
LDOUBLE, LDOUBLE,
0, 0, 1, 1, 1, "long double" } },
{ VOID, { -1, -1,
VOID, VOID,
0, 0, 0, 0, 0, "void" } },
VOID, VOID,
0, 0, 0, 0, 0, "void" } },
{ STRUCT, { -1, -1,
STRUCT, STRUCT,
0, 0, 0, 0, 0, "struct" } },
STRUCT, STRUCT,
0, 0, 0, 0, 0, "struct" } },
{ UNION, { -1, -1,
UNION, UNION,
0, 0, 0, 0, 0, "union" } },
UNION, UNION,
0, 0, 0, 0, 0, "union" } },
{ ENUM, { sizeof (int) * CHAR_BIT, 3 * CHAR_BIT,
ENUM, ENUM,
1, 0, 0, 1, 1, "enum" } },
ENUM, ENUM,
1, 0, 0, 1, 1, "enum" } },
{ PTR, { sizeof (void *) * CHAR_BIT, 4 * CHAR_BIT,
PTR, PTR,
0, 1, 0, 0, 1, "pointer" } },
PTR, PTR,
0, 1, 0, 0, 1, "pointer" } },
{ ARRAY, { -1, -1,
ARRAY, ARRAY,
0, 0, 0, 0, 0, "array" } },
ARRAY, ARRAY,
0, 0, 0, 0, 0, "array" } },
{ FUNC, { -1, -1,
FUNC, FUNC,
0, 0, 0, 0, 0, "function" } },
FUNC, FUNC,
0, 0, 0, 0, 0, "function" } },
};
/* declaration stack */
@ -293,6 +293,15 @@ void
addscl(sc)
scl_t sc;
{
if (sc == INLINE) {
/* syntax error */
gnuism(249);
if (dcs->d_inline)
/* duplicate '%s' */
warning(10, "inline");
dcs->d_inline = 1;
return;
}
if (dcs->d_type != NULL || dcs->d_atyp != NOTSPEC ||
dcs->d_smod != NOTSPEC || dcs->d_lmod != NOTSPEC) {
/* storage class after type is obsolescent */
@ -644,6 +653,7 @@ clrtyp()
dcs->d_scl = NOSCL;
dcs->d_type = NULL;
dcs->d_const = dcs->d_volatile = 0;
dcs->d_inline = 0;
dcs->d_mscl = dcs->d_terr = 0;
dcs->d_nedecl = 0;
}
@ -1693,11 +1703,7 @@ compltag(tp, fmem)
sp->memb = fmem;
if (sp->size == 0) {
/* zero sized %s */
if (gflag) {
warning(47, ttab[t].tt_name);
} else {
error(47, ttab[t].tt_name);
}
gnuism(47, ttab[t].tt_name);
} else {
n = 0;
for (mem = fmem; mem != NULL; mem = mem->s_nxt) {
@ -1790,6 +1796,15 @@ decl1ext(dsym, initflg)
if (dsym->s_type->t_tspec == FUNC && dsym->s_def == TDEF)
dsym->s_def = DECL;
if (dcs->d_inline) {
if (dsym->s_type->t_tspec == FUNC) {
dsym->s_inline = 1;
} else {
/* variable declared inline: %s */
warning(310, dsym->s_name);
}
}
/* Write the declaration into the output file */
if (plibflg && llibflg &&
dsym->s_type->t_tspec == FUNC && dsym->s_type->t_proto) {
@ -1800,7 +1815,7 @@ decl1ext(dsym, initflg)
rval = dsym->s_type->t_subt->t_tspec != VOID;
outfdef(dsym, dsym->s_type, &dsym->s_dpos, rval, 0, NULL);
} else {
outsym(dsym, dsym->s_scl);
outsym(dsym, dsym->s_scl, dsym->s_def);
}
if ((rdsym = dcs->d_rdcsym) != NULL) {
@ -1823,7 +1838,7 @@ decl1ext(dsym, initflg)
/*
* Overtake the rememberd params if the new symbol
* is no prototype.
* is not a prototype.
*/
if (rdsym->s_osdef && !dsym->s_type->t_proto) {
dsym->s_osdef = rdsym->s_osdef;
@ -1833,8 +1848,8 @@ decl1ext(dsym, initflg)
/*
* Remember the position of the declaration if the
* old symbols was a prototype and the new is not.
* Also remember the position if the old symbols
* old symbol was a prototype and the new is not.
* Also remember the position if the old symbol
* was defined and the new is not.
*/
if (rdsym->s_type->t_proto && !dsym->s_type->t_proto) {
@ -1853,6 +1868,10 @@ decl1ext(dsym, initflg)
if (rdsym->s_def == DEF)
dsym->s_def = DEF;
/* once a function is inline, it remains inline */
if (rdsym->s_inline)
dsym->s_inline = 1;
compltyp(dsym, rdsym);
}
@ -2261,6 +2280,10 @@ decl1arg(sym, initflg)
sym->s_type = gettyp(DOUBLE);
}
if (dcs->d_inline)
/* argument declared inline: %s */
warning(311, sym->s_name);
/*
* Arguments must have complete types. lengths() prints the needed
* error messages (null dimension is impossible because arrays are
@ -2454,6 +2477,22 @@ decl1loc(dsym, initflg)
}
}
/*
* functions may be declared inline at local scope, although
* this has no effect for a later definition of the same
* function.
* XXX it should have an effect if tflag is set. this would
* also be the way gcc behaves.
*/
if (dcs->d_inline) {
if (dsym->s_type->t_tspec == FUNC) {
dsym->s_inline = 1;
} else {
/* variable declared inline: %s */
warning(310, dsym->s_name);
}
}
chkfdef(dsym, 1);
chktyp(dsym);
@ -2467,9 +2506,9 @@ decl1loc(dsym, initflg)
* spaeter definiert wird, haben wir die Brille auf.
*/
if (dsym->s_xsym == NULL) {
outsym(dsym, EXTERN);
outsym(dsym, EXTERN, dsym->s_def);
} else {
outsym(dsym, dsym->s_xsym->s_scl);
outsym(dsym, dsym->s_xsym->s_scl, dsym->s_def);
}
}
@ -2996,8 +3035,9 @@ chkglvar(sym)
STRUCT_ASSIGN(curr_pos, sym->s_dpos);
if (sym->s_type->t_tspec == FUNC) {
if (sym->s_def == DEF) {
/* static function %s unused */
warning(236, sym->s_name);
if (!sym->s_inline)
/* static function %s unused */
warning(236, sym->s_name);
} else {
/* static function %s decl. but ... */
warning(290, sym->s_name);

View File

@ -1,4 +1,4 @@
/* $NetBSD: emit1.c,v 1.2 1995/07/03 21:24:02 cgd Exp $ */
/* $NetBSD: emit1.c,v 1.3 1995/10/02 17:14:14 jpo Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -32,7 +32,7 @@
*/
#ifndef lint
static char rcsid[] = "$NetBSD: emit1.c,v 1.2 1995/07/03 21:24:02 cgd Exp $";
static char rcsid[] = "$NetBSD: emit1.c,v 1.3 1995/10/02 17:14:14 jpo Exp $";
#endif
#include <ctype.h>
@ -199,16 +199,17 @@ outtt(tag, tdef)
}
/*
* write information about an global with storage class extern
* declared/defined symbol
* write information about an global declared/defined symbol
* with storage class extern
*
* informations about function definitions are written in outfdef(),
* not here
*/
void
outsym(sym, sc)
sym_t *sym;
outsym(sym, sc, def)
sym_t *sym;
scl_t sc;
def_t def;
{
/*
* Static function declarations must also be written to the output
@ -235,7 +236,7 @@ outsym(sym, sc)
/* flags */
switch (sym->s_def) {
switch (def) {
case DEF:
/* defined */
outchar('d');
@ -251,7 +252,7 @@ outsym(sym, sc)
default:
lerror("outsym() 2");
}
if (llibflg && sym->s_def != DECL) {
if (llibflg && def != DECL) {
/*
* mark it as used so we get no warnings from lint2 about
* unused symbols in libraries.

View File

@ -1,4 +1,4 @@
/* $NetBSD: err.c,v 1.2 1995/07/03 21:24:04 cgd Exp $ */
/* $NetBSD: err.c,v 1.3 1995/10/02 17:14:17 jpo Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -32,7 +32,7 @@
*/
#ifndef lint
static char rcsid[] = "$NetBSD: err.c,v 1.2 1995/07/03 21:24:04 cgd Exp $";
static char rcsid[] = "$NetBSD: err.c,v 1.3 1995/10/02 17:14:17 jpo Exp $";
#endif
/* number of errors found */
@ -51,6 +51,9 @@ int sytxerr;
#include "lint1.h"
static const char *basename __P((const char *));
static void verror __P((int, va_list));
static void vwarning __P((int, va_list));
const char *msgs[] = {
"syntax error: empty declaration", /* 0 */
@ -363,6 +366,8 @@ 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 */
};
/*
@ -388,45 +393,66 @@ basename(path)
return (*cp1 == '\0' ? cp2 : cp1);
}
#ifdef __STDC__
void
error(int n, ...)
{
#else
void
error(va_alist)
va_dcl
{
static void
verror(n, ap)
int n;
#endif
va_list ap;
{
const char *fn;
#ifdef __STDC__
va_start(ap, n);
#else
va_start(ap);
n = va_arg(ap, int);
#endif
fn = basename(curr_pos.p_file);
(void)printf("%s(%d): ", fn, curr_pos.p_line);
(void)vprintf(msgs[n], ap);
(void)printf("\n");
nerr++;
}
static void
vwarning(n, ap)
int n;
va_list ap;
{
const char *fn;
if (lline == isrcline || lline + 1 == isrcline)
/* this warning is suppressed by a LINTED comment */
return;
fn = basename(curr_pos.p_file);
(void)printf("%s(%d): warning: ", fn, curr_pos.p_line);
(void)vprintf(msgs[n], ap);
(void)printf("\n");
}
void
#ifdef __STDC__
error(int n, ...)
#else
error(n, va_alist)
int n;
va_dcl
#endif
{
va_list ap;
#ifdef __STDC__
va_start(ap, n);
#else
va_start(ap);
#endif
verror(n, ap);
va_end(ap);
}
void
#ifdef __STDC__
void
lerror(const char *msg, ...)
{
#else
void
lerror(va_alist)
va_dcl
{
lerror(msg, va_alist)
const char *msg;
va_dcl
#endif
{
va_list ap;
const char *fn;
@ -434,7 +460,6 @@ lerror(va_alist)
va_start(ap, msg);
#else
va_start(ap);
msg = va_arg(ap, const char *);
#endif
fn = basename(curr_pos.p_file);
(void)fprintf(stderr, "%s(%d): lint error: ", fn, curr_pos.p_line);
@ -444,48 +469,35 @@ lerror(va_alist)
exit(1);
}
void
#ifdef __STDC__
void
warning(int n, ...)
{
#else
void
warning(va_alist)
va_dcl
warning(n, va_alist)
int n;
{
va_dcl
#endif
{
va_list ap;
const char *fn;
#ifdef __STDC__
va_start(ap, n);
#else
va_start(ap);
n = va_arg(ap, int);
#endif
if (lline == isrcline || lline + 1 == isrcline)
/* this warning is suppressed by a LINTED comment */
return;
fn = basename(curr_pos.p_file);
(void)printf("%s(%d): warning: ", fn, curr_pos.p_line);
(void)vprintf(msgs[n], ap);
(void)printf("\n");
vwarning(n, ap);
va_end(ap);
}
void
#ifdef __STDC__
void
message(int n, ...)
{
#else
void
message(va_alist)
va_dcl
{
message(n, va_alist)
int n;
va_dcl
#endif
{
va_list ap;
const char *fn;
@ -493,7 +505,6 @@ message(va_alist)
va_start(ap, n);
#else
va_start(ap);
n = va_arg(ap, int);
#endif
fn = basename(curr_pos.p_file);
(void)printf("%s(%d): ", fn, curr_pos.p_line);
@ -501,3 +512,27 @@ message(va_alist)
(void)printf("\n");
va_end(ap);
}
void
#ifdef __STDC__
gnuism(int n, ...)
#else
gnuism(n, va_alist)
int n;
va_dcl
#endif
{
va_list ap;
#ifdef __STDC__
va_start(ap, n);
#else
va_start(ap);
#endif
if (sflag && !gflag) {
verror(n, ap);
} else if (!(!sflag && gflag)) {
vwarning(n, ap);
}
va_end(ap);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: externs1.h,v 1.2 1995/07/03 21:24:08 cgd Exp $ */
/* $NetBSD: externs1.h,v 1.3 1995/10/02 17:14:22 jpo Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -115,6 +115,7 @@ extern const char *msgs[];
extern void error __P((int, ...));
extern void warning __P((int, ...));
extern void message __P((int, ...));
extern void gnuism __P((int, ...));
extern void lerror __P((const char *, ...));
/*
@ -270,7 +271,7 @@ extern void mkinit __P((tnode_t *));
*/
extern void outtype __P((type_t *));
extern const char *ttos __P((type_t *));
extern void outsym __P((sym_t *, scl_t));
extern void outsym __P((sym_t *, scl_t, def_t));
extern void outfdef __P((sym_t *, type_t *, pos_t *, int, int, sym_t *));
extern void outcall __P((tnode_t *, int, int));
extern void outusg __P((sym_t *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: func.c,v 1.3 1995/10/02 17:08:38 jpo Exp $ */
/* $NetBSD: func.c,v 1.4 1995/10/02 17:14:26 jpo Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -32,7 +32,7 @@
*/
#ifndef lint
static char rcsid[] = "$NetBSD: func.c,v 1.3 1995/10/02 17:08:38 jpo Exp $";
static char rcsid[] = "$NetBSD: func.c,v 1.4 1995/10/02 17:14:26 jpo Exp $";
#endif
#include <stdlib.h>
@ -235,7 +235,7 @@ funcdef(fsym)
error(67);
}
fsym->s_def = fsym->s_def = DEF;
fsym->s_def = DEF;
if (fsym->s_scl == TYPEDEF) {
fsym->s_scl = EXTERN;
@ -243,6 +243,9 @@ funcdef(fsym)
error(8);
}
if (dcs->d_inline)
fsym->s_inline = 1;
/*
* Arguments in new style function declarations need a name.
* (void is already removed from the list of arguments)
@ -305,6 +308,10 @@ funcdef(fsym)
/* complete the type */
compltyp(fsym, rdsym);
/* once a function is inline it remains inline */
if (rdsym->s_inline)
fsym->s_inline = 1;
}
/* remove the old symbol from the symbol table */
@ -363,11 +370,17 @@ funcend()
nargusg = -1;
/*
* Write the information about the function definition to the
* write the information about the function definition to the
* output file
* inline functions explicitely declared extern are written as
* declarations only.
*/
outfdef(funcsym, dcs->d_ftype, &dcs->d_fdpos, cstk->c_retval,
funcsym->s_osdef, dcs->d_fargs);
if (dcs->d_scl == EXTERN && funcsym->s_inline) {
outsym(funcsym, funcsym->s_scl, DECL);
} else {
outfdef(funcsym, dcs->d_ftype, &dcs->d_fdpos, cstk->c_retval,
funcsym->s_osdef, dcs->d_fargs);
}
if (funcsym->s_type->t_proto) {
/* from now the prototype is valid */

View File

@ -1,4 +1,4 @@
/* $NetBSD: init.c,v 1.2 1995/07/03 21:24:15 cgd Exp $ */
/* $NetBSD: init.c,v 1.3 1995/10/02 17:14:31 jpo Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -32,7 +32,7 @@
*/
#ifndef lint
static char rcsid[] = "$NetBSD: init.c,v 1.2 1995/07/03 21:24:15 cgd Exp $";
static char rcsid[] = "$NetBSD: init.c,v 1.3 1995/10/02 17:14:31 jpo Exp $";
#endif
#include <stdlib.h>
@ -430,9 +430,9 @@ mkinit(tn)
sym = NULL;
offs = 0;
if (conaddr(tn, &sym, &offs) == -1) {
if (gflag && (sc == AUTO || sc == REG)) {
if (sc == AUTO || sc == REG) {
/* non-constant initializer */
warning(177);
gnuism(177);
} else {
/* non-constant initializer */
error(177);

View File

@ -1,4 +1,4 @@
/* $NetBSD: lint1.h,v 1.3 1995/10/02 17:08:40 jpo Exp $ */
/* $NetBSD: lint1.h,v 1.4 1995/10/02 17:14:35 jpo Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -177,8 +177,9 @@ typedef enum {
ENUMCON, /* enumerator */
ABSTRACT, /* abstract symbol (sizeof, casts, unnamed argument) */
ARG, /* argument */
PARG /* used in declaration stack during prototype
PARG, /* used in declaration stack during prototype
declaration */
INLINE /* only used by the parser */
} scl_t;
/*
@ -203,6 +204,7 @@ typedef struct sym {
definition */
u_int s_rimpl : 1; /* return value of function implizit decl. */
u_int s_osdef : 1; /* symbol stems from old style function def. */
u_int s_inline : 1; /* true if this is a inline function */
struct sym *s_xsym; /* for local declared external symbols pointer
to external symbol with same name */
def_t s_def; /* declared, tentative defined, defined */
@ -300,6 +302,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_inline : 1; /* inline in declaration specifiers */
u_int d_mscl : 1; /* multiple storage classes */
u_int d_terr : 1; /* invalid type combination */
u_int d_nedecl : 1; /* 1 if at least a tag is declared */

View File

@ -1,5 +1,5 @@
%{
/* $NetBSD: scan.l,v 1.3 1995/10/02 17:08:43 jpo Exp $ */
/* $NetBSD: scan.l,v 1.4 1995/10/02 17:14:40 jpo Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -33,7 +33,7 @@
*/
#ifndef lint
static char rcsid[] = "$NetBSD: scan.l,v 1.3 1995/10/02 17:08:43 jpo Exp $";
static char rcsid[] = "$NetBSD: scan.l,v 1.4 1995/10/02 17:14:40 jpo Exp $";
#endif
#include <stdlib.h>
@ -189,39 +189,40 @@ static struct kwtab {
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 */
} 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 },
{"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 },
{ "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 }
};
/* Symbol table */

View File

@ -1,4 +1,4 @@
/* $NetBSD: tree.c,v 1.4 1995/10/02 17:08:47 jpo Exp $ */
/* $NetBSD: tree.c,v 1.5 1995/10/02 17:14:44 jpo Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -32,7 +32,7 @@
*/
#ifndef lint
static char rcsid[] = "$NetBSD: tree.c,v 1.4 1995/10/02 17:08:47 jpo Exp $";
static char rcsid[] = "$NetBSD: tree.c,v 1.5 1995/10/02 17:14:44 jpo Exp $";
#endif
#include <stdlib.h>
@ -729,12 +729,8 @@ cconv(tn)
if (tn->tn_type->t_tspec == ARRAY) {
if (!tn->tn_lvalue) {
/* %soperand of '%s' must be lvalue */
if (gflag) {
/* XXX print correct operator */
warning(114, "", modtab[AMPER].m_name);
} else {
error(114, "", modtab[AMPER].m_name);
}
/* XXX print correct operator */
gnuism(114, "", modtab[AMPER].m_name);
}
tn = mktnode(AMPER, tincref(tn->tn_type->t_subt, PTR),
tn, NULL);
@ -2626,11 +2622,7 @@ plength(tp)
break;
case VOID:
/* cannot do pointer arithmetic on operand of ... */
if (gflag) {
warning(136);
} else {
error(136);
}
gnuism(136);
break;
case STRUCT:
case UNION: