Hello Pietro.

Thanks for the patch.  See a couple of comments below.

> 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.
>
> Signed-off-by: Pietro Monteiro <[email protected]>
> ---
>  gcc/algol68/a68-parser-prelude.cc          |  9 +++++++++
>  gcc/algol68/ga68.texi                      | 18 +++++++++++++++++-
>  gcc/testsuite/algol68/compile/floor-1.a68  |  4 ++++
>  gcc/testsuite/algol68/execute/entier-1.a68 |  5 ++++-
>  4 files changed, 34 insertions(+), 2 deletions(-)
>  create mode 100644 gcc/testsuite/algol68/compile/floor-1.a68
>
> diff --git a/gcc/algol68/a68-parser-prelude.cc 
> b/gcc/algol68/a68-parser-prelude.cc
> index 67edf55f9f7..953fba3556b 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 da19ddbb329..f66f798a2f3 100644
> --- a/gcc/algol68/ga68.texi
> +++ b/gcc/algol68/ga68.texi
> @@ -2631,9 +2631,13 @@ 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}}

Nice catch, adding that missing @B{l}

>  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 +2974,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 +3078,17 @@ 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{int}}

But it is also required here...

> +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 00000000000..ae1a23356bc
> --- /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 d7c84e23d3e..a7ca3803e5a 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
>
> base-commit: be277865c4d2a820f9f43873b4dde8a6d78c494c

Reply via email to