From 24e3f8417e861321d1f934d52fd33535e08d9817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Ko=C5=9Bcielnicki?= Date: Sat, 1 Feb 2020 17:23:05 +0100 Subject: json: fix handling of 32-bit parameters See YosysHQ/yosys#1671 for rationale. Also, added some validation to our parser, so that out-of-range values are reported and the user knows they should update yosys. --- frontend/json_frontend.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'frontend/json_frontend.cc') diff --git a/frontend/json_frontend.cc b/frontend/json_frontend.cc index f1310e71..136786fc 100644 --- a/frontend/json_frontend.cc +++ b/frontend/json_frontend.cc @@ -105,10 +105,14 @@ struct JsonFrontendImpl Property parse_property(const Json &val) const { - if (val.is_number()) + if (val.is_number()) { + if (val.int_value() != val.number_value()) + log_error("Found an out-of-range integer parameter in the JSON file.\n" + "Please regenerate the input file with an up-to-date version of yosys.\n"); return Property(val.int_value(), 32); - else + } else { return Property::from_string(val.string_value()); + } } template void foreach_attr(const Json &obj, TFunc Func) const -- cgit v1.2.3