add support for ({}) gcc shit.

This commit is contained in:
christos 2002-10-22 22:50:11 +00:00
parent 06374318c8
commit 5a3a9e9ea9
5 changed files with 59 additions and 17 deletions

View File

@ -1,5 +1,5 @@
%{
/* $NetBSD: cgram.y,v 1.28 2002/10/22 18:15:00 christos Exp $ */
/* $NetBSD: cgram.y,v 1.29 2002/10/22 22:50:11 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.28 2002/10/22 18:15:00 christos Exp $");
__RCSID("$NetBSD: cgram.y,v 1.29 2002/10/22 22:50:11 christos Exp $");
#endif
#include <stdlib.h>
@ -242,6 +242,8 @@ static __inline void RESTORE(void)
%type <y_sym> parameter_type_list
%type <y_sym> parameter_declaration
%type <y_tnode> expr
%type <y_tnode> expr_stmnt_val
%type <y_tnode> expr_stmnt_list
%type <y_tnode> term
%type <y_tnode> func_arg_list
%type <y_op> point_or_arrow
@ -1252,11 +1254,11 @@ label:
;
comp_stmnt:
compstmnt_lbrace declaration_list opt_stmnt_list compstmnt_rbrace
| compstmnt_lbrace opt_stmnt_list compstmnt_rbrace
comp_stmnt_lbrace declaration_list opt_stmnt_list comp_stmnt_rbrace
| comp_stmnt_lbrace opt_stmnt_list comp_stmnt_rbrace
;
compstmnt_lbrace:
comp_stmnt_lbrace:
T_LBRACE {
blklev++;
mblklev++;
@ -1264,7 +1266,7 @@ compstmnt_lbrace:
}
;
compstmnt_rbrace:
comp_stmnt_rbrace:
T_RBRACE {
popdecl();
freeblk();
@ -1289,7 +1291,7 @@ stmnt_list:
expr_stmnt:
expr T_SEMI {
expr($1, 0, 0);
expr($1, 0, 0, 1);
ftflg = 0;
}
| T_SEMI {
@ -1297,6 +1299,22 @@ expr_stmnt:
}
;
expr_stmnt_val:
expr T_SEMI {
/* XXX: We should really do that only on the last name */
if ($1->tn_op == NAME)
$1->tn_sym->s_used = 1;
$$ = $1;
expr($1, 0, 0, 0);
ftflg = 0;
}
;
expr_stmnt_list:
expr_stmnt_val
| expr_stmnt_list expr_stmnt_val
;
selection_stmnt:
if_without_else {
SAVE();
@ -1538,6 +1556,26 @@ term:
$2->tn_parn = 1;
$$ = $2;
}
| T_LPARN comp_stmnt_lbrace declaration_list expr_stmnt_list {
blklev--;
mblklev--;
initsym = mktempsym($4->tn_type);
mblklev++;
blklev++;
gnuism(320);
} comp_stmnt_rbrace T_RPARN {
$$ = getnnode(initsym, 0);
}
| T_LPARN comp_stmnt_lbrace expr_stmnt_list {
blklev--;
mblklev--;
initsym = mktempsym($3->tn_type);
mblklev++;
blklev++;
gnuism(320);
} comp_stmnt_rbrace T_RPARN {
$$ = getnnode(initsym, 0);
}
| term T_INCDEC {
$$ = build($2 == INC ? INCAFT : DECAFT, $1, NULL);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: err.c,v 1.23 2002/10/22 18:15:00 christos Exp $ */
/* $NetBSD: err.c,v 1.24 2002/10/22 22:50:11 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.23 2002/10/22 18:15:00 christos Exp $");
__RCSID("$NetBSD: err.c,v 1.24 2002/10/22 22:50:11 christos Exp $");
#endif
#include <sys/types.h>
@ -375,6 +375,7 @@ const char *msgs[] = {
"__func__ is a C9X feature", /* 317 */
"variable array dimension is a GCC extension", /* 318 */
"compound literals are a C9X/GCC extension", /* 319 */
"({ }) is a GCC extension", /* 320 */
};
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: externs1.h,v 1.18 2002/10/22 18:15:00 christos Exp $ */
/* $NetBSD: externs1.h,v 1.19 2002/10/22 22:50:11 christos Exp $ */
/*
* Copyright (c) 1994, 1995 Jochen Pohl
@ -203,7 +203,7 @@ 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 *, int);
extern void expr(tnode_t *, int, int);
extern void expr(tnode_t *, int, int, int);
extern void chkmisc(tnode_t *, int, int, int, int, int, int);
extern int conaddr(tnode_t *, sym_t **, ptrdiff_t *);
extern strg_t *catstrg(strg_t *, strg_t *);

View File

@ -1,5 +1,5 @@
%{
/* $NetBSD: scan.l,v 1.30 2002/10/22 21:09:34 christos Exp $ */
/* $NetBSD: scan.l,v 1.31 2002/10/22 22:50:11 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: scan.l,v 1.30 2002/10/22 21:09:34 christos Exp $");
__RCSID("$NetBSD: scan.l,v 1.31 2002/10/22 22:50:11 christos Exp $");
#endif
#include <stdlib.h>
@ -1350,6 +1350,8 @@ mktempsym(type_t *t)
sym->s_blklev = blklev;
sym->s_scl = AUTO;
sym->s_kind = FVFT;
sym->s_used = 1;
sym->s_set = 1;
if ((sym->s_link = symtab[h]) != NULL)
symtab[h]->s_rlink = &sym->s_link;

View File

@ -1,4 +1,4 @@
/* $NetBSD: tree.c,v 1.33 2002/10/22 21:09:35 christos Exp $ */
/* $NetBSD: tree.c,v 1.34 2002/10/22 22:50:11 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.33 2002/10/22 21:09:35 christos Exp $");
__RCSID("$NetBSD: tree.c,v 1.34 2002/10/22 22:50:11 christos Exp $");
#endif
#include <stdlib.h>
@ -3346,7 +3346,7 @@ constant(tnode_t *tn, int required)
* for the expression.
*/
void
expr(tnode_t *tn, int vctx, int tctx)
expr(tnode_t *tn, int vctx, int tctx, int freeblk)
{
if (tn == NULL && nerr == 0)
@ -3383,6 +3383,7 @@ expr(tnode_t *tn, int vctx, int tctx)
displexpr(tn, 0);
/* free the tree memory */
if (freeblk)
tfreeblk();
}