From 71b1546a7dd8d704a0c76f0a4262e3bd4b2c07d3 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sun, 17 May 2015 21:59:05 +0100 Subject: [PATCH] Fail gracefully when an unpacked struct is declared. --- parse.y | 6 +++++- pform_struct_type.cc | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/parse.y b/parse.y index 948437000..787f409cb 100644 --- a/parse.y +++ b/parse.y @@ -1044,7 +1044,11 @@ data_type /* IEEE1800-2005: A.2.2.1 */ $$ = tmp; } | struct_data_type - { $$ = $1; } + { if (!$1->packed_flag) { + yyerror(@1, "sorry: Unpacked structs not supported."); + } + $$ = $1; + } | enum_data_type { $$ = $1; } | atom2_type signed_unsigned_opt diff --git a/pform_struct_type.cc b/pform_struct_type.cc index 766fc77e3..433e66a91 100644 --- a/pform_struct_type.cc +++ b/pform_struct_type.cc @@ -79,8 +79,8 @@ static void pform_set_struct_type(struct_type_t*struct_type, perm_string name, N return; } - // For now, can only handle packed structs. - ivl_assert(*struct_type, 0); + // For now, can only handle packed structs. The parser generates + // a "sorry" message, so no need to do anything here. } void pform_set_struct_type(struct_type_t*struct_type, list*names, NetNet::Type net_type, list*attr)