diff options
author | Tom Tromey <tromey@adacore.com> | 2023-04-19 09:40:20 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-05-12 12:30:28 -0600 |
commit | 9c0fb73485cb2c90bb10cb4d3cf1d27e36f9ff01 (patch) | |
tree | 88f1ca4555a484b28c4fcbe822ac8c925835fd8b /gdb/compile | |
parent | 14e8fded85efa824e6652ed876229e5c24758b72 (diff) | |
download | binutils-9c0fb73485cb2c90bb10cb4d3cf1d27e36f9ff01.zip binutils-9c0fb73485cb2c90bb10cb4d3cf1d27e36f9ff01.tar.gz binutils-9c0fb73485cb2c90bb10cb4d3cf1d27e36f9ff01.tar.bz2 |
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.
Diffstat (limited to 'gdb/compile')
-rw-r--r-- | gdb/compile/compile-c-types.c | 2 | ||||
-rw-r--r-- | gdb/compile/compile-cplus-types.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c index f48eca2..4853c3f 100644 --- a/gdb/compile/compile-c-types.c +++ b/gdb/compile/compile-c-types.c @@ -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) diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c index 2f87ad8..d8e305f 100644 --- a/gdb/compile/compile-cplus-types.c +++ b/gdb/compile/compile-cplus-types.c @@ -455,7 +455,7 @@ compile_cplus_convert_array (compile_cplus_instance *instance, struct type *range = type->index_type (); gcc_type element_type = instance->convert_type (type->target_type ()); - if (range->bounds ()->low.kind () != PROP_CONST) + if (!range->bounds ()->low.is_constant ()) { const char *s = _("array type with non-constant" " lower bound is not supported"); |