Defer Ada character literal resolution

In Ada, an enumeration type can use a character literal as one of the
enumerators.  The Ada expression parser handles the appropriate
conversion.

It turns out, though, that this conversion was handled incorrectly.
For an expression like TYPE'(EXP), the conversion would be done for
any such literal appearing in EXP -- but only the outermost such
expression should really be affected.

This patch defers the conversion until the resolution phase, fixing
the bug.
This commit is contained in:
Tom Tromey
2021-07-01 11:36:58 -06:00
parent 8b12db26d1
commit 03adb248d6
7 changed files with 204 additions and 44 deletions

View File

@@ -742,6 +742,35 @@ private:
operation_up m_val;
};
/* A character constant expression. This is a separate operation so
that it can participate in resolution, so that TYPE'(CST) can
work correctly for enums with character enumerators. */
class ada_char_operation : public long_const_operation,
public ada_resolvable
{
public:
using long_const_operation::long_const_operation;
bool resolve (struct expression *exp,
bool deprocedure_p,
bool parse_completion,
innermost_block_tracker *tracker,
struct type *context_type) override
{
/* This should never be called, because this class also implements
'replace'. */
gdb_assert_not_reached ("unexpected call");
}
operation_up replace (operation_up &&owner,
struct expression *exp,
bool deprocedure_p,
bool parse_completion,
innermost_block_tracker *tracker,
struct type *context_type) override;
};
} /* namespace expr */
#endif /* ADA_EXP_H */