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

@@ -176,11 +176,11 @@ f_language::f_type_print_varspec_suffix (struct type *type,
else if (type_not_allocated (type))
print_rank_only = true;
else if ((TYPE_ASSOCIATED_PROP (type)
&& PROP_CONST != TYPE_ASSOCIATED_PROP (type)->kind ())
&& !TYPE_ASSOCIATED_PROP (type)->is_constant ())
|| (TYPE_ALLOCATED_PROP (type)
&& PROP_CONST != TYPE_ALLOCATED_PROP (type)->kind ())
&& !TYPE_ALLOCATED_PROP (type)->is_constant ())
|| (TYPE_DATA_LOCATION (type)
&& PROP_CONST != TYPE_DATA_LOCATION (type)->kind ()))
&& !TYPE_DATA_LOCATION (type)->is_constant ()))
{
/* This case exist when we ptype a typename which has the dynamic
properties but cannot be resolved as there is no object. */
@@ -395,7 +395,7 @@ f_language::f_type_print_base (struct type *type, struct ui_file *stream,
asked to print the type of a value with a dynamic type then the
bounds will not have been resolved. */
if (type->bounds ()->high.kind () == PROP_CONST)
if (type->bounds ()->high.is_constant ())
{
LONGEST upper_bound = f77_get_upperbound (type);