[Ada] Do not rewrite argument of pragma Entry_Queue_Length in analysis

Message ID 20190821083142.GA71862@adacore.com
State New
Headers show
  • [Ada] Do not rewrite argument of pragma Entry_Queue_Length in analysis
Related show

Commit Message

Pierre-Marie de Rodat Aug. 21, 2019, 8:31 a.m.
It was unusual for the analysis phase of compiler to rewrite static
expression of pragma Entry_Queue_Length with its value. This typically
happens when expanding the AST and only if needed for a given backend.
In particular, GNATprove doesn't need such an expansion and actually
needs the unrewritten AST to detect references to constants declared
with SPARK_Mode => Off within a code with SPARK_Mode => On.

This change has no impact on compilation, so no frontend test is

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

2019-08-21  Piotr Trojanek  <trojanek@adacore.com>


	* sem_prag.adb (Max_Entry_Queue_Length): Do not substitute
	expression of the pragma argument with its value during
	* sem_util.adb (Get_Max_Queue_Length): Compute value of the
	pragma argument when needed.


--- gcc/ada/sem_prag.adb
+++ gcc/ada/sem_prag.adb
@@ -19599,15 +19599,6 @@  package body Sem_Prag is
             end if;
-            --  Manually substitute the expression value of the pragma argument
-            --  if it's not an integer literal because this is not taken care
-            --  of automatically elsewhere.
-            if Nkind (Arg) /= N_Integer_Literal then
-               Rewrite (Arg, Make_Integer_Literal (Sloc (Arg), Val));
-               Set_Etype (Arg, Etype (Original_Node (Arg)));
-            end if;
             Record_Rep_Item (Entry_Id, N);
          end Max_Entry_Queue_Length;

--- gcc/ada/sem_util.adb
+++ gcc/ada/sem_util.adb
@@ -9763,7 +9763,8 @@  package body Sem_Util is
          return Uint_0;
       end if;
-      Max := Intval (Expression (First (Pragma_Argument_Associations (Prag))));
+      Max := Expr_Value
+        (Expression (First (Pragma_Argument_Associations (Prag))));
       --  Since -1 and 0 are equivalent, return 0 for instances of -1 for
       --  uniformity.