[Ada] Prevent use of an uninitialized AST field with universal integer

Message ID 20211020192738.GA3154162@adacore.com
State Committed
Headers
Series [Ada] Prevent use of an uninitialized AST field with universal integer |

Commit Message

Pierre-Marie de Rodat Oct. 20, 2021, 7:27 p.m. UTC
  A temporary workaround needed by GNATprove after cleaning up the
handling of AST fields with universal integers.

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

gcc/ada/

	* exp_spark.adb (Expand_SPARK_N_Attribute_Reference): Guard
	against equality of an uninitialized RM_Size field.
  

Patch

diff --git a/gcc/ada/exp_spark.adb b/gcc/ada/exp_spark.adb
--- a/gcc/ada/exp_spark.adb
+++ b/gcc/ada/exp_spark.adb
@@ -451,6 +451,7 @@  package body Exp_SPARK is
                Apply_Universal_Integer_Attribute_Checks (N);
 
                if Present (Typ)
+                 and then Known_RM_Size (Typ)
                  and then RM_Size (Typ) = RM_Size (Standard_Long_Long_Integer)
                then
                   --  ??? This should rather be a range check, but this would