Fix malloc/free and new/delete problems, plus some initializations.

This patch fixes some allocation problems (mostly in the parser
and lexor relating to identifiers). It also fixes a couple places
where uninitialized variables were used. All found with valgrind.
There are still 100 tests that have problems. Many of these appear
to be related.
This commit is contained in:
Cary R 2008-03-27 20:30:53 -07:00 committed by Stephen Williams
parent bb14ac1fe0
commit b5b5a9935c
4 changed files with 81 additions and 71 deletions

View File

@ -4,7 +4,7 @@
%{ %{
/* /*
* Copyright (c) 1998-2007 Stephen Williams (steve@icarus.com) * Copyright (c) 1998-2008 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -48,6 +48,11 @@
*/ */
extern YYLTYPE yylloc; extern YYLTYPE yylloc;
static char* strdupnew(char const *str)
{
return str ? strcpy(new char [strlen(str)+1], str) : 0;
}
static const char* set_file_name(char*text) static const char* set_file_name(char*text)
{ {
perm_string path = filename_strings.make(text); perm_string path = filename_strings.make(text);
@ -205,7 +210,7 @@ W [ \t\b\f\r]+
int rc = lexor_keyword_code(yytext, yyleng); int rc = lexor_keyword_code(yytext, yyleng);
switch (rc) { switch (rc) {
case IDENTIFIER: case IDENTIFIER:
yylval.text = strdup(yytext); yylval.text = strdupnew(yytext);
if (strncmp(yylval.text,"PATHPULSE$", 10) == 0) if (strncmp(yylval.text,"PATHPULSE$", 10) == 0)
rc = PATHPULSE_IDENTIFIER; rc = PATHPULSE_IDENTIFIER;
break; break;
@ -214,7 +219,7 @@ W [ \t\b\f\r]+
case K_logic: case K_logic:
case K_wone: case K_wone:
if (! gn_cadence_types_enabled()) { if (! gn_cadence_types_enabled()) {
yylval.text = strdup(yytext); yylval.text = strdupnew(yytext);
rc = IDENTIFIER; rc = IDENTIFIER;
} else { } else {
yylval.text = 0; yylval.text = 0;
@ -235,7 +240,7 @@ W [ \t\b\f\r]+
\\[^ \t\b\f\r\n]+ { \\[^ \t\b\f\r\n]+ {
yylval.text = strdup(yytext+1); yylval.text = strdupnew(yytext+1);
return IDENTIFIER; } return IDENTIFIER; }
\$([a-zA-Z0-9$_]+) { \$([a-zA-Z0-9$_]+) {
@ -255,7 +260,7 @@ W [ \t\b\f\r]+
return K_Ssetup; return K_Ssetup;
if (strcmp(yytext,"$width") == 0) if (strcmp(yytext,"$width") == 0)
return K_Swidth; return K_Swidth;
yylval.text = strdup(yytext); yylval.text = strdupnew(yytext);
return SYSTEM_IDENTIFIER; } return SYSTEM_IDENTIFIER; }
@ -978,5 +983,5 @@ void reset_lexor()
yylloc.first_line = 1; yylloc.first_line = 1;
/* Announce the first file name. */ /* Announce the first file name. */
yylloc.text = set_file_name(strdup(vl_file.c_str())); yylloc.text = set_file_name(strdupnew(vl_file.c_str()));
} }

View File

@ -398,8 +398,8 @@ const Link& NetDelaySrc::condit_pin() const
NetNet::NetNet(NetScope*s, perm_string n, Type t, unsigned npins) NetNet::NetNet(NetScope*s, perm_string n, Type t, unsigned npins)
: NetObj(s, n, 1), sig_next_(0), sig_prev_(0), : NetObj(s, n, 1), sig_next_(0), sig_prev_(0),
type_(t), port_type_(NOT_A_PORT), data_type_(IVL_VT_NO_TYPE), type_(t), port_type_(NOT_A_PORT), data_type_(IVL_VT_NO_TYPE),
signed_(false), msb_(npins-1), lsb_(0), dimensions_(0), s0_(0), e0_(0), signed_(false), isint_(false), msb_(npins-1), lsb_(0), dimensions_(0),
local_flag_(false), eref_count_(0), lref_count_(0) s0_(0), e0_(0), local_flag_(false), eref_count_(0), lref_count_(0)
{ {
assert(s); assert(s);
assert(npins>0); assert(npins>0);
@ -438,7 +438,7 @@ NetNet::NetNet(NetScope*s, perm_string n, Type t,
: NetObj(s, n, 1), : NetObj(s, n, 1),
sig_next_(0), sig_prev_(0), type_(t), sig_next_(0), sig_prev_(0), type_(t),
port_type_(NOT_A_PORT), data_type_(IVL_VT_NO_TYPE), signed_(false), port_type_(NOT_A_PORT), data_type_(IVL_VT_NO_TYPE), signed_(false),
msb_(ms), lsb_(ls), dimensions_(0), s0_(0), e0_(0), isint_(false), msb_(ms), lsb_(ls), dimensions_(0), s0_(0), e0_(0),
local_flag_(false), eref_count_(0), lref_count_(0) local_flag_(false), eref_count_(0), lref_count_(0)
{ {
assert(s); assert(s);
@ -484,8 +484,8 @@ static unsigned calculate_count(long s, long e)
NetNet::NetNet(NetScope*s, perm_string n, Type t, NetNet::NetNet(NetScope*s, perm_string n, Type t,
long ms, long ls, long array_s, long array_e) long ms, long ls, long array_s, long array_e)
: NetObj(s, n, calculate_count(array_s, array_e)), : NetObj(s, n, calculate_count(array_s, array_e)),
sig_next_(0), sig_prev_(0), type_(t), sig_next_(0), sig_prev_(0), type_(t), port_type_(NOT_A_PORT),
port_type_(NOT_A_PORT), data_type_(IVL_VT_NO_TYPE), signed_(false), data_type_(IVL_VT_NO_TYPE), signed_(false), isint_(false),
msb_(ms), lsb_(ls), dimensions_(1), s0_(array_s), e0_(array_e), msb_(ms), lsb_(ls), dimensions_(1), s0_(array_s), e0_(array_e),
local_flag_(false), eref_count_(0), lref_count_(0) local_flag_(false), eref_count_(0), lref_count_(0)
{ {

123
parse.y
View File

@ -81,14 +81,14 @@ static list<perm_string>* list_from_identifier(char*id)
{ {
list<perm_string>*tmp = new list<perm_string>; list<perm_string>*tmp = new list<perm_string>;
tmp->push_back(lex_strings.make(id)); tmp->push_back(lex_strings.make(id));
delete id; delete[]id;
return tmp; return tmp;
} }
static list<perm_string>* list_from_identifier(list<perm_string>*tmp, char*id) static list<perm_string>* list_from_identifier(list<perm_string>*tmp, char*id)
{ {
tmp->push_back(lex_strings.make(id)); tmp->push_back(lex_strings.make(id));
delete id; delete[]id;
return tmp; return tmp;
} }
@ -325,7 +325,7 @@ attribute
{ named_pexpr_t*tmp = new named_pexpr_t; { named_pexpr_t*tmp = new named_pexpr_t;
tmp->name = lex_strings.make($1); tmp->name = lex_strings.make($1);
tmp->parm = 0; tmp->parm = 0;
delete $1; delete[]$1;
$$ = tmp; $$ = tmp;
} }
| IDENTIFIER '=' expression | IDENTIFIER '=' expression
@ -339,7 +339,7 @@ attribute
named_pexpr_t*tmp2 = new named_pexpr_t; named_pexpr_t*tmp2 = new named_pexpr_t;
tmp2->name = lex_strings.make($1); tmp2->name = lex_strings.make($1);
tmp2->parm = tmp; tmp2->parm = tmp;
delete $1; delete[]$1;
$$ = tmp2; $$ = tmp2;
} }
; ;
@ -611,7 +611,7 @@ delay_value_simple
{ PEIdent*tmp = new PEIdent(lex_strings.make($1)); { PEIdent*tmp = new PEIdent(lex_strings.make($1));
FILE_NAME(tmp, @1); FILE_NAME(tmp, @1);
$$ = tmp; $$ = tmp;
delete $1; delete[]$1;
} }
; ;
@ -621,7 +621,7 @@ description
| KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' | KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')'
{ perm_string tmp3 = lex_strings.make($3); { perm_string tmp3 = lex_strings.make($3);
pform_set_type_attrib(tmp3, $5, $7); pform_set_type_attrib(tmp3, $5, $7);
delete $3; delete[]$3;
delete $5; delete $5;
} }
; ;
@ -1034,7 +1034,7 @@ expr_primary
PECallFunction*tmp = new PECallFunction(tn); PECallFunction*tmp = new PECallFunction(tn);
FILE_NAME(tmp, @1); FILE_NAME(tmp, @1);
$$ = tmp; $$ = tmp;
delete $1; delete[]$1;
} }
/* The hierarchy_identifier rule matches simple identifiers as well as /* The hierarchy_identifier rule matches simple identifiers as well as
@ -1061,6 +1061,7 @@ expr_primary
{ perm_string tn = lex_strings.make($1); { perm_string tn = lex_strings.make($1);
PECallFunction*tmp = new PECallFunction(tn, *$3); PECallFunction*tmp = new PECallFunction(tn, *$3);
FILE_NAME(tmp, @1); FILE_NAME(tmp, @1);
delete[]$1;
$$ = tmp; $$ = tmp;
} }
@ -1192,7 +1193,7 @@ gate_instance
tmp->parms = $3; tmp->parms = $3;
tmp->file = @1.text; tmp->file = @1.text;
tmp->lineno = @1.first_line; tmp->lineno = @1.first_line;
delete $1; delete[]$1;
$$ = tmp; $$ = tmp;
} }
@ -1205,7 +1206,7 @@ gate_instance
tmp->range[1] = (*rng)[1]; tmp->range[1] = (*rng)[1];
tmp->file = @1.text; tmp->file = @1.text;
tmp->lineno = @1.first_line; tmp->lineno = @1.first_line;
delete $1; delete[]$1;
delete rng; delete rng;
$$ = tmp; $$ = tmp;
} }
@ -1230,7 +1231,7 @@ gate_instance
tmp->range[1] = (*rng)[1]; tmp->range[1] = (*rng)[1];
tmp->file = @1.text; tmp->file = @1.text;
tmp->lineno = @1.first_line; tmp->lineno = @1.first_line;
delete $1; delete[]$1;
delete rng; delete rng;
$$ = tmp; $$ = tmp;
} }
@ -1244,7 +1245,7 @@ gate_instance
tmp->parms_by_name = $3; tmp->parms_by_name = $3;
tmp->file = @1.text; tmp->file = @1.text;
tmp->lineno = @1.first_line; tmp->lineno = @1.first_line;
delete $1; delete[]$1;
$$ = tmp; $$ = tmp;
} }
@ -1258,7 +1259,7 @@ gate_instance
tmp->range[1] = (*rng)[1]; tmp->range[1] = (*rng)[1];
tmp->file = @1.text; tmp->file = @1.text;
tmp->lineno = @1.first_line; tmp->lineno = @1.first_line;
delete $1; delete[]$1;
delete rng; delete rng;
$$ = tmp; $$ = tmp;
} }
@ -1318,12 +1319,12 @@ hierarchy_identifier
: IDENTIFIER : IDENTIFIER
{ $$ = new pform_name_t; { $$ = new pform_name_t;
$$->push_back(name_component_t(lex_strings.make($1))); $$->push_back(name_component_t(lex_strings.make($1)));
delete $1; delete[]$1;
} }
| hierarchy_identifier '.' IDENTIFIER | hierarchy_identifier '.' IDENTIFIER
{ pform_name_t * tmp = $1; { pform_name_t * tmp = $1;
tmp->push_back(name_component_t(lex_strings.make($3))); tmp->push_back(name_component_t(lex_strings.make($3)));
delete $3; delete[]$3;
$$ = tmp; $$ = tmp;
} }
| hierarchy_identifier '[' expression ']' | hierarchy_identifier '[' expression ']'
@ -1439,7 +1440,7 @@ list_of_port_declarations
port_declaration_context.sign_flag, port_declaration_context.sign_flag,
port_declaration_context.range, 0); port_declaration_context.range, 0);
delete $1; delete $1;
delete $3; delete[]$3;
$$ = tmp; $$ = tmp;
} }
| list_of_port_declarations ',' | list_of_port_declarations ','
@ -1468,7 +1469,7 @@ port_declaration
port_declaration_context.sign_flag = $4; port_declaration_context.sign_flag = $4;
port_declaration_context.range = $5; port_declaration_context.range = $5;
delete $1; delete $1;
delete $6; delete[]$6;
$$ = ptmp; $$ = ptmp;
} }
| attribute_list_opt | attribute_list_opt
@ -1484,7 +1485,7 @@ port_declaration
port_declaration_context.sign_flag = $4; port_declaration_context.sign_flag = $4;
port_declaration_context.range = $5; port_declaration_context.range = $5;
delete $1; delete $1;
delete $6; delete[]$6;
$$ = ptmp; $$ = ptmp;
} }
| attribute_list_opt | attribute_list_opt
@ -1500,7 +1501,7 @@ port_declaration
port_declaration_context.sign_flag = $4; port_declaration_context.sign_flag = $4;
port_declaration_context.range = $5; port_declaration_context.range = $5;
delete $1; delete $1;
delete $6; delete[]$6;
$$ = ptmp; $$ = ptmp;
} }
| attribute_list_opt | attribute_list_opt
@ -1516,7 +1517,7 @@ port_declaration
port_declaration_context.sign_flag = $4; port_declaration_context.sign_flag = $4;
port_declaration_context.range = $5; port_declaration_context.range = $5;
delete $1; delete $1;
delete $6; delete[]$6;
$$ = ptmp; $$ = ptmp;
} }
| attribute_list_opt | attribute_list_opt
@ -1538,7 +1539,7 @@ port_declaration
pform_make_reginit(@6, name, $8); pform_make_reginit(@6, name, $8);
delete $1; delete $1;
delete $6; delete[]$6;
$$ = ptmp; $$ = ptmp;
} }
; ;
@ -1607,7 +1608,7 @@ module : attribute_list_opt module_start IDENTIFIER
module_item_list_opt module_item_list_opt
K_endmodule K_endmodule
{ pform_endmodule($3); { pform_endmodule($3);
delete $3; delete[]$3;
} }
; ;
@ -1804,13 +1805,14 @@ module_item
IDENTIFIER parameter_value_opt gate_instance_list ';' IDENTIFIER parameter_value_opt gate_instance_list ';'
{ perm_string tmp1 = lex_strings.make($2); { perm_string tmp1 = lex_strings.make($2);
pform_make_modgates(tmp1, $3, $4); pform_make_modgates(tmp1, $3, $4);
delete $2; delete[]$2;
if ($1) delete $1; if ($1) delete $1;
} }
| attribute_list_opt | attribute_list_opt
IDENTIFIER parameter_value_opt error ';' IDENTIFIER parameter_value_opt error ';'
{ yyerror(@2, "error: Invalid module instantiation"); { yyerror(@2, "error: Invalid module instantiation");
delete[]$2;
if ($1) delete $1; if ($1) delete $1;
} }
@ -1854,7 +1856,7 @@ module_item
current_task->set_statement($6); current_task->set_statement($6);
pform_pop_scope(); pform_pop_scope();
current_task = 0; current_task = 0;
delete $2; delete[]$2;
} }
| K_task IDENTIFIER | K_task IDENTIFIER
@ -1870,7 +1872,7 @@ module_item
current_task->set_statement($9); current_task->set_statement($9);
pform_pop_scope(); pform_pop_scope();
current_task = 0; current_task = 0;
delete $2; delete[]$2;
} }
/* The function declaration rule matches the function declaration /* The function declaration rule matches the function declaration
@ -1890,7 +1892,7 @@ module_item
current_function->set_return($2); current_function->set_return($2);
pform_pop_scope(); pform_pop_scope();
current_function = 0; current_function = 0;
delete $3; delete[]$3;
} }
/* A generate region can contain further module items. Actually, it /* A generate region can contain further module items. Actually, it
@ -1981,7 +1983,7 @@ module_item
{ perm_string tmp3 = lex_strings.make($3); { perm_string tmp3 = lex_strings.make($3);
perm_string tmp5 = lex_strings.make($5); perm_string tmp5 = lex_strings.make($5);
pform_set_attrib(tmp3, tmp5, $7); pform_set_attrib(tmp3, tmp5, $7);
delete $3; delete[]$3;
delete $5; delete $5;
} }
| KK_attribute '(' error ')' ';' | KK_attribute '(' error ')' ';'
@ -2041,7 +2043,7 @@ net_decl_assign
tmp->next = tmp; tmp->next = tmp;
tmp->name = lex_strings.make($1); tmp->name = lex_strings.make($1);
tmp->expr = $3; tmp->expr = $3;
delete $1; delete[]$1;
$$ = tmp; $$ = tmp;
} }
; ;
@ -2124,7 +2126,7 @@ parameter_assign
active_signed, active_signed,
active_range, tmp); active_range, tmp);
} }
delete $1; delete[]$1;
} }
; ;
@ -2146,7 +2148,7 @@ localparam_assign
active_signed, active_signed,
active_range, tmp); active_range, tmp);
} }
delete $1; delete[]$1;
} }
; ;
@ -2224,14 +2226,14 @@ parameter_value_byname
{ named_pexpr_t*tmp = new named_pexpr_t; { named_pexpr_t*tmp = new named_pexpr_t;
tmp->name = lex_strings.make($2); tmp->name = lex_strings.make($2);
tmp->parm = $4; tmp->parm = $4;
free($2); delete[]$2;
$$ = tmp; $$ = tmp;
} }
| '.' IDENTIFIER '(' ')' | '.' IDENTIFIER '(' ')'
{ named_pexpr_t*tmp = new named_pexpr_t; { named_pexpr_t*tmp = new named_pexpr_t;
tmp->name = lex_strings.make($2); tmp->name = lex_strings.make($2);
tmp->parm = 0; tmp->parm = 0;
free($2); delete[]$2;
$$ = tmp; $$ = tmp;
} }
; ;
@ -2276,7 +2278,7 @@ port
| '.' IDENTIFIER '(' port_reference ')' | '.' IDENTIFIER '(' port_reference ')'
{ Module::port_t*tmp = $4; { Module::port_t*tmp = $4;
tmp->name = lex_strings.make($2); tmp->name = lex_strings.make($2);
delete $2; delete[]$2;
$$ = tmp; $$ = tmp;
} }
@ -2296,7 +2298,7 @@ port
| '.' IDENTIFIER '(' '{' port_reference_list '}' ')' | '.' IDENTIFIER '(' '{' port_reference_list '}' ')'
{ Module::port_t*tmp = $5; { Module::port_t*tmp = $5;
tmp->name = lex_strings.make($2); tmp->name = lex_strings.make($2);
delete $2; delete[]$2;
$$ = tmp; $$ = tmp;
} }
; ;
@ -2323,7 +2325,7 @@ port_reference
{ Module::port_t*ptmp; { Module::port_t*ptmp;
perm_string name = lex_strings.make($1); perm_string name = lex_strings.make($1);
ptmp = pform_module_port_reference(name, @1.text, @1.first_line); ptmp = pform_module_port_reference(name, @1.text, @1.first_line);
delete $1; delete[]$1;
$$ = ptmp; $$ = ptmp;
} }
@ -2355,7 +2357,7 @@ port_reference
ptmp->expr = svector<PEIdent*>(1); ptmp->expr = svector<PEIdent*>(1);
ptmp->expr[0] = wtmp; ptmp->expr[0] = wtmp;
delete $1; delete[]$1;
$$ = ptmp; $$ = ptmp;
} }
@ -2382,7 +2384,7 @@ port_reference
ptmp->name = perm_string(); ptmp->name = perm_string();
ptmp->expr = svector<PEIdent*>(1); ptmp->expr = svector<PEIdent*>(1);
ptmp->expr[0] = tmp; ptmp->expr[0] = tmp;
delete $1; delete[]$1;
$$ = ptmp; $$ = ptmp;
} }
@ -2394,7 +2396,7 @@ port_reference
ptmp->name = lex_strings.make($1); ptmp->name = lex_strings.make($1);
ptmp->expr = svector<PEIdent*>(1); ptmp->expr = svector<PEIdent*>(1);
ptmp->expr[0] = wtmp; ptmp->expr[0] = wtmp;
delete $1; delete[]$1;
$$ = ptmp; $$ = ptmp;
} }
; ;
@ -2420,7 +2422,7 @@ port_name
{ named_pexpr_t*tmp = new named_pexpr_t; { named_pexpr_t*tmp = new named_pexpr_t;
tmp->name = lex_strings.make($2); tmp->name = lex_strings.make($2);
tmp->parm = $4; tmp->parm = $4;
delete $2; delete[]$2;
$$ = tmp; $$ = tmp;
} }
| '.' IDENTIFIER '(' error ')' | '.' IDENTIFIER '(' error ')'
@ -2428,14 +2430,14 @@ port_name
named_pexpr_t*tmp = new named_pexpr_t; named_pexpr_t*tmp = new named_pexpr_t;
tmp->name = lex_strings.make($2); tmp->name = lex_strings.make($2);
tmp->parm = 0; tmp->parm = 0;
delete $2; delete[]$2;
$$ = tmp; $$ = tmp;
} }
| '.' IDENTIFIER '(' ')' | '.' IDENTIFIER '(' ')'
{ named_pexpr_t*tmp = new named_pexpr_t; { named_pexpr_t*tmp = new named_pexpr_t;
tmp->name = lex_strings.make($2); tmp->name = lex_strings.make($2);
tmp->parm = 0; tmp->parm = 0;
delete $2; delete[]$2;
$$ = tmp; $$ = tmp;
} }
; ;
@ -2811,7 +2813,7 @@ specparam
: IDENTIFIER '=' expression : IDENTIFIER '=' expression
{ PExpr*tmp = $3; { PExpr*tmp = $3;
pform_set_specparam(lex_strings.make($1), tmp); pform_set_specparam(lex_strings.make($1), tmp);
delete $1; delete[]$1;
} }
| IDENTIFIER '=' expression ':' expression ':' expression | IDENTIFIER '=' expression ':' expression ':' expression
{ PExpr*tmp = 0; { PExpr*tmp = 0;
@ -2849,14 +2851,14 @@ specparam
min_typ_max_warn -= 1; min_typ_max_warn -= 1;
} }
pform_set_specparam(lex_strings.make($1), tmp); pform_set_specparam(lex_strings.make($1), tmp);
delete $1; delete[]$1;
} }
| PATHPULSE_IDENTIFIER '=' expression | PATHPULSE_IDENTIFIER '=' expression
{ delete $1; { delete[]$1;
delete $3; delete $3;
} }
| PATHPULSE_IDENTIFIER '=' '(' expression ',' expression ')' | PATHPULSE_IDENTIFIER '=' '(' expression ',' expression ')'
{ delete $1; { delete[]$1;
delete $4; delete $4;
delete $6; delete $6;
} }
@ -2925,7 +2927,7 @@ spec_notifier
| spec_notifier ',' hierarchy_identifier | spec_notifier ',' hierarchy_identifier
{ delete $3; } { delete $3; }
| IDENTIFIER | IDENTIFIER
{ delete $1; } { delete[]$1; }
; ;
@ -2988,7 +2990,7 @@ statement
PBlock*tmp = current_block_stack.top(); PBlock*tmp = current_block_stack.top();
current_block_stack.pop(); current_block_stack.pop();
tmp->set_statement(*$6); tmp->set_statement(*$6);
delete $3; delete[]$3;
delete $6; delete $6;
$$ = tmp; $$ = tmp;
} }
@ -3000,6 +3002,7 @@ statement
| K_begin ':' IDENTIFIER K_end | K_begin ':' IDENTIFIER K_end
{ PBlock*tmp = new PBlock(PBlock::BL_SEQ); { PBlock*tmp = new PBlock(PBlock::BL_SEQ);
FILE_NAME(tmp, @1); FILE_NAME(tmp, @1);
delete[]$3;
$$ = tmp; $$ = tmp;
} }
| K_begin error K_end | K_begin error K_end
@ -3022,7 +3025,7 @@ statement
PBlock*tmp = current_block_stack.top(); PBlock*tmp = current_block_stack.top();
current_block_stack.pop(); current_block_stack.pop();
tmp->set_statement(*$6); tmp->set_statement(*$6);
delete $3; delete[]$3;
delete $6; delete $6;
$$ = tmp; $$ = tmp;
} }
@ -3034,7 +3037,7 @@ statement
| K_fork ':' IDENTIFIER K_join | K_fork ':' IDENTIFIER K_join
{ PBlock*tmp = new PBlock(PBlock::BL_PAR); { PBlock*tmp = new PBlock(PBlock::BL_PAR);
FILE_NAME(tmp, @1); FILE_NAME(tmp, @1);
delete $3; delete[]$3;
$$ = tmp; $$ = tmp;
} }
@ -3235,7 +3238,7 @@ statement
| SYSTEM_IDENTIFIER '(' expression_list_with_nuls ')' ';' | SYSTEM_IDENTIFIER '(' expression_list_with_nuls ')' ';'
{ PCallTask*tmp = new PCallTask(lex_strings.make($1), *$3); { PCallTask*tmp = new PCallTask(lex_strings.make($1), *$3);
FILE_NAME(tmp,@1); FILE_NAME(tmp,@1);
delete $1; delete[]$1;
delete $3; delete $3;
$$ = tmp; $$ = tmp;
} }
@ -3243,7 +3246,7 @@ statement
{ svector<PExpr*>pt (0); { svector<PExpr*>pt (0);
PCallTask*tmp = new PCallTask(lex_strings.make($1), pt); PCallTask*tmp = new PCallTask(lex_strings.make($1), pt);
FILE_NAME(tmp,@1); FILE_NAME(tmp,@1);
delete $1; delete[]$1;
$$ = tmp; $$ = tmp;
} }
| hierarchy_identifier '(' expression_list_proper ')' ';' | hierarchy_identifier '(' expression_list_proper ')' ';'
@ -3576,13 +3579,13 @@ udp_comb_entry_list
: udp_comb_entry : udp_comb_entry
{ list<string>*tmp = new list<string>; { list<string>*tmp = new list<string>;
tmp->push_back($1); tmp->push_back($1);
delete $1; delete[]$1;
$$ = tmp; $$ = tmp;
} }
| udp_comb_entry_list udp_comb_entry | udp_comb_entry_list udp_comb_entry
{ list<string>*tmp = $1; { list<string>*tmp = $1;
tmp->push_back($2); tmp->push_back($2);
delete $2; delete[]$2;
$$ = tmp; $$ = tmp;
} }
; ;
@ -3591,13 +3594,13 @@ udp_sequ_entry_list
: udp_sequ_entry : udp_sequ_entry
{ list<string>*tmp = new list<string>; { list<string>*tmp = new list<string>;
tmp->push_back($1); tmp->push_back($1);
delete $1; delete[]$1;
$$ = tmp; $$ = tmp;
} }
| udp_sequ_entry_list udp_sequ_entry | udp_sequ_entry_list udp_sequ_entry
{ list<string>*tmp = $1; { list<string>*tmp = $1;
tmp->push_back($2); tmp->push_back($2);
delete $2; delete[]$2;
$$ = tmp; $$ = tmp;
} }
; ;
@ -3622,7 +3625,7 @@ udp_initial
PEIdent*itmp = new PEIdent(lex_strings.make($2)); PEIdent*itmp = new PEIdent(lex_strings.make($2));
PAssign*atmp = new PAssign(itmp, etmp); PAssign*atmp = new PAssign(itmp, etmp);
FILE_NAME(atmp, @2); FILE_NAME(atmp, @2);
delete $2; delete[]$2;
$$ = atmp; $$ = atmp;
} }
; ;
@ -3695,7 +3698,7 @@ udp_port_decl
svector<PWire*>*tmp = new svector<PWire*>(1); svector<PWire*>*tmp = new svector<PWire*>(1);
(*tmp)[0] = pp; (*tmp)[0] = pp;
$$ = tmp; $$ = tmp;
delete $2; delete[]$2;
} }
| K_reg IDENTIFIER ';' | K_reg IDENTIFIER ';'
{ perm_string pname = lex_strings.make($2); { perm_string pname = lex_strings.make($2);
@ -3703,7 +3706,7 @@ udp_port_decl
svector<PWire*>*tmp = new svector<PWire*>(1); svector<PWire*>*tmp = new svector<PWire*>(1);
(*tmp)[0] = pp; (*tmp)[0] = pp;
$$ = tmp; $$ = tmp;
delete $2; delete[]$2;
} }
| K_reg K_output IDENTIFIER ';' | K_reg K_output IDENTIFIER ';'
{ perm_string pname = lex_strings.make($3); { perm_string pname = lex_strings.make($3);
@ -3711,7 +3714,7 @@ udp_port_decl
svector<PWire*>*tmp = new svector<PWire*>(1); svector<PWire*>*tmp = new svector<PWire*>(1);
(*tmp)[0] = pp; (*tmp)[0] = pp;
$$ = tmp; $$ = tmp;
delete $3; delete[]$3;
} }
; ;
@ -3730,13 +3733,13 @@ udp_port_list
: IDENTIFIER : IDENTIFIER
{ list<perm_string>*tmp = new list<perm_string>; { list<perm_string>*tmp = new list<perm_string>;
tmp->push_back(lex_strings.make($1)); tmp->push_back(lex_strings.make($1));
delete $1; delete[]$1;
$$ = tmp; $$ = tmp;
} }
| udp_port_list ',' IDENTIFIER | udp_port_list ',' IDENTIFIER
{ list<perm_string>*tmp = $1; { list<perm_string>*tmp = $1;
tmp->push_back(lex_strings.make($3)); tmp->push_back(lex_strings.make($3));
delete $3; delete[]$3;
$$ = tmp; $$ = tmp;
} }
; ;

View File

@ -1246,6 +1246,8 @@ void dll_target::udp(const NetUDP*net)
u->sequ = net->is_sequential(); u->sequ = net->is_sequential();
if (u->sequ) if (u->sequ)
u->init = net->get_initial(); u->init = net->get_initial();
else
u->init = 'x';
u->name = net->udp_name(); u->name = net->udp_name();
string inp; string inp;
char out; char out;