https://gcc.gnu.org/g:e9d363b4987c4b10126a567284fecba3e7f5b71c
commit r17-633-ge9d363b4987c4b10126a567284fecba3e7f5b71c Author: Pietro Monteiro <[email protected]> Date: Wed May 20 19:33:35 2026 -0400 algol68: Add FLOOR as synonym for ENTIER The Revised Report{10.2.3.4.r} specifies ENTIER as the monadic operator that yields the greatest integral value less than or equal to a real value (i.e., rounds toward negative infinity). Many programming languages call this operator FLOOR. Add FLOOR as a synonym for ENTIER to allow use of the familiar name; no semantic change is introduced. gcc/algol68/ChangeLog: * a68-parser-prelude.cc (gnu_prelude): Map FLOOR(L real):L int to ENTIER(L real):L int. * ga68.texi: Add a section for real operators in the Extended prelude chapter and document FLOOR. gcc/testsuite/ChangeLog: * algol68/execute/entier-1.a68: Add test for FLOOR = ENTIER. * algol68/compile/floor-1.a68: New test. Diff: --- gcc/algol68/a68-parser-prelude.cc | 9 +++++++++ gcc/algol68/ga68.texi | 16 +++++++++++++++- gcc/testsuite/algol68/compile/floor-1.a68 | 4 ++++ gcc/testsuite/algol68/execute/entier-1.a68 | 5 ++++- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/gcc/algol68/a68-parser-prelude.cc b/gcc/algol68/a68-parser-prelude.cc index 67edf55f9f7b..953fba3556bb 100644 --- a/gcc/algol68/a68-parser-prelude.cc +++ b/gcc/algol68/a68-parser-prelude.cc @@ -1378,6 +1378,15 @@ gnu_prelude (void) a68_op (A68_EXT, "CLEAR", m, a68_lower_clear3); m = a68_proc (M_BOOL, M_LONG_LONG_BITS, M_INT, NO_MOID); a68_op (A68_EXT, "TEST", m, a68_lower_test3); + /* REAL operators. */ + m = a68_proc (M_INT, M_REAL, NO_MOID); + a68_op (A68_EXT, "FLOOR", m, a68_lower_entier2); + /* LONG REAL operators. */ + m = a68_proc (M_LONG_INT, M_LONG_REAL, NO_MOID); + a68_op (A68_EXT, "FLOOR", m, a68_lower_entier2); + /* LONG REAL operators. */ + m = a68_proc (M_LONG_LONG_INT, M_LONG_LONG_REAL, NO_MOID); + a68_op (A68_EXT, "FLOOR", m, a68_lower_entier2); } /* POSIX prelude. */ diff --git a/gcc/algol68/ga68.texi b/gcc/algol68/ga68.texi index da19ddbb329a..ce1e984ad781 100644 --- a/gcc/algol68/ga68.texi +++ b/gcc/algol68/ga68.texi @@ -2631,9 +2631,12 @@ to @code{b}. Monadic operator that yields the nearest integer to its operand. @end deftypefn -@deftypefn Operator {} {@B{entier}} {= (@B{l} @B{real} a) @B{int}} +@deftypefn Operator {} {@B{entier}} {= (@B{l} @B{real} a) @B{l} @B{int}} Monadic operator that yields the integer equal to @code{a}, or the next integer below (more negative than) @code{a}. + +Selecting the @option{gnu68} dialect provides the @B{floor} +operator as a synonym for @B{entier}. @xref{Extended real operators}. @end deftypefn @deftypefn Operator {} {@B{shorten}} {= (@B{long} @B{real} a) @B{real}} @@ -2970,6 +2973,7 @@ which is the default. * Extended rows operators:: Rows and associated operations. * Extended boolean operators:: Operations on boolean operands. * Extended bits operators:: Bits and associated operations. +* Extended real operators:: Operations on real operands. * Extended math procedures:: Mathematical constants and functions. @end menu @@ -3073,6 +3077,16 @@ is not in the range @code{0,L_bits_width)} then the operator yields @B{false}. @end deftypefn +@node Extended real operators +@section Extended real operators + +@deftypefn Operator {} {@B{floor}} {= (@B{l} @B{real} a) @B{l} @B{int}} +Monadic operator that yields the integer equal to @code{a} rounded +towards negative infinity. + +An alias for operator @B{entier}. @xref{Real operators}. +@end deftypefn + @node Extended math procedures @section Extended math procedures diff --git a/gcc/testsuite/algol68/compile/floor-1.a68 b/gcc/testsuite/algol68/compile/floor-1.a68 new file mode 100644 index 000000000000..ae1a23356bc7 --- /dev/null +++ b/gcc/testsuite/algol68/compile/floor-1.a68 @@ -0,0 +1,4 @@ +# { dg-options "-fstropping=upper -std=algol68" } # +BEGIN # FLOOR is a GNU extension # + FLOOR 1.2 # { dg-error "indicant FLOOR has not been declared properly" } # +END diff --git a/gcc/testsuite/algol68/execute/entier-1.a68 b/gcc/testsuite/algol68/execute/entier-1.a68 index d7c84e23d3e6..a7ca3803e5ad 100644 --- a/gcc/testsuite/algol68/execute/entier-1.a68 +++ b/gcc/testsuite/algol68/execute/entier-1.a68 @@ -4,5 +4,8 @@ BEGIN REAL x = 3.14, y = 3.80; LONG LONG REAL xxx = LONG LONG 3.14, yyy = LONG LONG 3.80; ASSERT (ENTIER x = 3 AND ENTIER y = 3); ASSERT (ENTIER xx = LONG 3 AND ENTIER yy = LONG 3); - ASSERT (ENTIER xxx = LONG LONG 3 AND ENTIER yyy = LONG LONG 3) + ASSERT (ENTIER xxx = LONG LONG 3 AND ENTIER yyy = LONG LONG 3); + ASSERT (ENTIER x = 3 AND FLOOR y = 3); + ASSERT (ENTIER xx = LONG 3 AND FLOOR yy = LONG 3); + ASSERT (ENTIER xxx = LONG LONG 3 AND FLOOR yyy = LONG LONG 3) END
