gnu/gcc/f95105f02768d3ca404ea5afc846d378fe1e16a2 a68: improve diagnostics for malformed modes
An Algol 68 mode can be non well formed for two reasons:
- When the mode denotes values that are infinite in size.
- When the mode is strongly coercible to itself.
The yin-yang algorithm implemented by is_well_formed is currently
just reporting a boolean indicating whether the given mode is well
formed.
This patch changes is_well_formed so it returns also the reason for
the particular mode to not be ok: missing a yin means an infinite
mode, whereas missing a yang means the mode is strongly coercible to
itself.
This allows to improve diagnostics, guiding the user on why the mode
is not well formed.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog
* a68-parser-modes.cc (WELL): Define.
(NO_YIN): Likewise.
(NO_YANG): Likewise.
(UNWELL): Likewise.
(is_well_formed): Discriminate reason for the given mode to not be
well formed.
(a68_make_moid_list): Emit note explaining why a mode is not well
formed.
gcc/testsuite/ChangeLog
* algol68/compile/malformed-mode-1.a68: New test.
* algol68/compile/malformed-mode-2.a68: Likewise.
3 files changed