Skip to content

Commit f83bc88

Browse files
committed
SystemVerilog: const
1 parent 31c4ec8 commit f83bc88

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/verilog/parser.y

+6-2
Original file line numberDiff line numberDiff line change
@@ -1381,20 +1381,24 @@ data_declaration:
13811381
const_opt TOK_VAR lifetime_opt data_type_or_implicit list_of_variable_decl_assignments ';'
13821382
{ init($$, ID_decl);
13831383
stack_expr($$).set(ID_class, ID_var);
1384-
addswap($$, ID_type, $4);
1384+
add_as_subtype(stack_type($1), stack_type($4));
1385+
addswap($$, ID_type, $1);
13851386
swapop($$, $5); }
13861387
| const_opt lifetime_opt data_type list_of_variable_decl_assignments ';'
13871388
{ init($$, ID_decl);
13881389
stack_expr($$).set(ID_class, ID_reg);
1389-
addswap($$, ID_type, $3);
1390+
add_as_subtype(stack_type($1), stack_type($3));
1391+
addswap($$, ID_type, $1);
13901392
swapop($$, $4); }
13911393
| type_declaration
13921394
| package_import_declaration
13931395
;
13941396

13951397
const_opt:
13961398
/* Optional */
1399+
{ init($$, ID_nil); }
13971400
| TOK_CONST
1401+
{ init($$, ID_const); stack_type($$).add_subtype().make_nil(); }
13981402
;
13991403

14001404
package_import_declaration_brace:

src/verilog/verilog_elaborate_type.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,13 @@ typet verilog_typecheck_exprt::elaborate_type(const typet &src)
468468
tmp.subtype() = elaborate_type(tmp.subtype());
469469
return std::move(tmp);
470470
}
471+
else if(src.id() == ID_const)
472+
{
473+
auto tmp = to_type_with_subtype(src).subtype();
474+
elaborate_type(tmp);
475+
tmp.set(ID_C_constant, true);
476+
return tmp;
477+
}
471478
else
472479
{
473480
throw errort().with_location(source_location)

0 commit comments

Comments
 (0)