The test presented below illustrates the current patch.

------------
-- Source --
------------

with System.Dim.Mks;    use System.Dim.Mks;
with System.Dim.Mks_IO; use System.Dim.Mks_IO;

procedure Main is
begin
   for N in -3 .. +3 loop
      Put (m**N , Aft => 2, Exp => 0);
   end loop;
end Main;

-----------------
-- Compilation --
-----------------

$ gcc -c -gnat12 main.adb
main.adb:7:13: exponent of dimensioned operand must be known at compile-time
compilation abandoned due to previous error

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-08-06  Vincent Pucci  <pu...@adacore.com>

        * sem_dim.adb (Analyze_Dimension_Binary_Op): Issue an error message
        for unknown exponent at compile-time.

Index: sem_dim.adb
===================================================================
--- sem_dim.adb (revision 190155)
+++ sem_dim.adb (working copy)
@@ -1322,9 +1322,12 @@
                --  value of the exponent must be known compile time. Otherwise,
                --  the exponentiation evaluation will return an error message.
 
-               if L_Has_Dimensions
-                 and then Compile_Time_Known_Value (R)
-               then
+               if L_Has_Dimensions then
+                  if not Compile_Time_Known_Value (R) then
+                     Error_Msg_N ("exponent of dimensioned operand must be " &
+                                  "known at compile-time", N);
+                  end if;
+
                   declare
                      Exponent_Value : Rational := Zero;
 

Reply via email to