Add dynamic_prop::is_constant

I noticed many spots checking whether a dynamic property's kind is
PROP_CONST.  Some spots, I think, are doing a slightly incorrect check
-- checking for != PROP_UNDEFINED where == PROP_CONST is actually
required, the key thing being that const_val may only be called for
PROP_CONST properties.

This patch adds dynamic::is_constant and then updates these checks to
use it.

Regression tested on x86-64 Fedora 36.
This commit is contained in:
Tom Tromey
2023-04-19 09:40:20 -06:00
parent 14e8fded85
commit 9c0fb73485
14 changed files with 45 additions and 43 deletions

View File

@@ -44,7 +44,7 @@ convert_array (compile_c_instance *context, struct type *type)
element_type = context->convert_type (type->target_type ());
if (range->bounds ()->low.kind () != PROP_CONST)
if (!range->bounds ()->low.is_constant ())
return context->plugin ().error (_("array type with non-constant"
" lower bound is not supported"));
if (range->bounds ()->low.const_val () != 0)