add variable array dimension.

This commit is contained in:
christos 2002-10-22 13:48:50 +00:00
parent 742633f2d2
commit 8c326659c6
5 changed files with 31 additions and 27 deletions

View File

@ -1,5 +1,5 @@
%{
/* $NetBSD: cgram.y,v 1.26 2002/10/21 21:14:51 christos Exp $ */
/* $NetBSD: cgram.y,v 1.27 2002/10/22 13:48:51 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.26 2002/10/21 21:14:51 christos Exp $");
__RCSID("$NetBSD: cgram.y,v 1.27 2002/10/22 13:48:51 christos Exp $");
#endif
#include <stdlib.h>
@ -64,7 +64,7 @@ int mblklev;
*/
static int onowarn = -1;
static int toicon(tnode_t *);
static int toicon(tnode_t *, int);
static void idecl(sym_t *, int, sbuf_t *);
static void ignuptorp(void);
@ -681,12 +681,12 @@ notype_member_decl:
$$ = $1;
}
| notype_decl T_COLON constant {
$$ = bitfield($1, toicon($3));
$$ = bitfield($1, toicon($3, 1));
}
| {
symtyp = FVFT;
} T_COLON constant {
$$ = bitfield(NULL, toicon($3));
$$ = bitfield(NULL, toicon($3, 1));
}
;
@ -695,12 +695,12 @@ type_member_decl:
$$ = $1;
}
| type_decl T_COLON constant {
$$ = bitfield($1, toicon($3));
$$ = bitfield($1, toicon($3, 1));
}
| {
symtyp = FVFT;
} T_COLON constant {
$$ = bitfield(NULL, toicon($3));
$$ = bitfield(NULL, toicon($3, 1));
}
;
@ -783,7 +783,7 @@ enumerator:
$$ = ename($1, enumval, 1);
}
| ename T_ASSIGN constant {
$$ = ename($1, toicon($3), 0);
$$ = ename($1, toicon($3, 1), 0);
}
;
@ -848,7 +848,7 @@ notype_direct_decl:
$$ = addarray($1, 0, 0);
}
| notype_direct_decl T_LBRACK constant T_RBRACK {
$$ = addarray($1, 1, toicon($3));
$$ = addarray($1, 1, toicon($3, 0));
}
| notype_direct_decl param_list {
$$ = addfunc($1, $2);
@ -877,7 +877,7 @@ type_direct_decl:
$$ = addarray($1, 0, 0);
}
| type_direct_decl T_LBRACK constant T_RBRACK {
$$ = addarray($1, 1, toicon($3));
$$ = addarray($1, 1, toicon($3, 0));
}
| type_direct_decl param_list {
$$ = addfunc($1, $2);
@ -913,7 +913,7 @@ direct_param_decl:
$$ = addarray($1, 0, 0);
}
| direct_param_decl T_LBRACK constant T_RBRACK {
$$ = addarray($1, 1, toicon($3));
$$ = addarray($1, 1, toicon($3, 0));
}
| direct_param_decl param_list {
$$ = addfunc($1, $2);
@ -942,7 +942,7 @@ direct_notype_param_decl:
$$ = addarray($1, 0, 0);
}
| direct_notype_param_decl T_LBRACK constant T_RBRACK {
$$ = addarray($1, 1, toicon($3));
$$ = addarray($1, 1, toicon($3, 0));
}
| direct_notype_param_decl param_list {
$$ = addfunc($1, $2);
@ -1200,13 +1200,13 @@ direct_abs_decl:
$$ = addarray(aname(), 0, 0);
}
| T_LBRACK constant T_RBRACK {
$$ = addarray(aname(), 1, toicon($2));
$$ = addarray(aname(), 1, toicon($2, 0));
}
| direct_abs_decl T_LBRACK T_RBRACK {
$$ = addarray($1, 0, 0);
}
| direct_abs_decl T_LBRACK constant T_RBRACK {
$$ = addarray($1, 1, toicon($3));
$$ = addarray($1, 1, toicon($3, 0));
}
| abs_decl_param_list {
$$ = addfunc(aname(), $1);
@ -1691,13 +1691,13 @@ q_gt(int64_t a, int64_t b)
* expressions, it frees the memory used for the expression.
*/
static int
toicon(tnode_t *tn)
toicon(tnode_t *tn, int required)
{
int i;
tspec_t t;
val_t *v;
v = constant(tn);
v = constant(tn, required);
/*
* Abstract declarations are used inside expression. To free

View File

@ -1,4 +1,4 @@
/* $NetBSD: err.c,v 1.21 2002/10/22 13:31:34 christos Exp $ */
/* $NetBSD: err.c,v 1.22 2002/10/22 13:48:50 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: err.c,v 1.21 2002/10/22 13:31:34 christos Exp $");
__RCSID("$NetBSD: err.c,v 1.22 2002/10/22 13:48:50 christos Exp $");
#endif
#include <sys/types.h>
@ -373,6 +373,7 @@ const char *msgs[] = {
"GCC style struct or union member name in initializer", /* 315 */
"__FUNCTION__ is a GCC extension", /* 316 */
"__func__ is a C9X feature", /* 317 */
"variable array dimension is a GCC extension", /* 318 */
};
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: externs1.h,v 1.16 2002/10/21 21:14:52 christos Exp $ */
/* $NetBSD: externs1.h,v 1.17 2002/10/22 13:48:52 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -200,7 +200,7 @@ extern tnode_t *bldszof(type_t *);
extern tnode_t *cast(tnode_t *, type_t *);
extern tnode_t *funcarg(tnode_t *, tnode_t *);
extern tnode_t *funccall(tnode_t *, tnode_t *);
extern val_t *constant(tnode_t *);
extern val_t *constant(tnode_t *, int);
extern void expr(tnode_t *, int, int);
extern void chkmisc(tnode_t *, int, int, int, int, int, int);
extern int conaddr(tnode_t *, sym_t **, ptrdiff_t *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: func.c,v 1.18 2002/09/13 14:59:24 christos Exp $ */
/* $NetBSD: func.c,v 1.19 2002/10/22 13:48:50 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: func.c,v 1.18 2002/09/13 14:59:24 christos Exp $");
__RCSID("$NetBSD: func.c,v 1.19 2002/10/22 13:48:50 christos Exp $");
#endif
#include <stdlib.h>
@ -464,7 +464,7 @@ label(int typ, sym_t *sym, tnode_t *tn)
* get the value of the expression and convert it
* to the type of the switch expression
*/
v = constant(tn);
v = constant(tn, 1);
(void) memset(&nv, 0, sizeof nv);
cvtcon(CASE, 0, ci->c_swtype, &nv, v);
free(v);

View File

@ -1,4 +1,4 @@
/* $NetBSD: tree.c,v 1.30 2002/10/22 13:31:34 christos Exp $ */
/* $NetBSD: tree.c,v 1.31 2002/10/22 13:48:51 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
__RCSID("$NetBSD: tree.c,v 1.30 2002/10/22 13:31:34 christos Exp $");
__RCSID("$NetBSD: tree.c,v 1.31 2002/10/22 13:48:51 christos Exp $");
#endif
#include <stdlib.h>
@ -3278,7 +3278,7 @@ parg( int n, /* pos of arg */
* type, an error message is printed.
*/
val_t *
constant(tnode_t *tn)
constant(tnode_t *tn, int required)
{
val_t *v;
@ -3313,7 +3313,10 @@ constant(tnode_t *tn)
}
/* integral constant expression expected */
error(55);
if (required)
error(55);
else
gnuism(318);
if (!isityp(v->v_tspec))
v->v_tspec = INT;