[Ada] Fix spurious ownership error in GNATprove
diff mbox series

Message ID 20190814095312.GA52035@adacore.com
State New
Headers show
Series
  • [Ada] Fix spurious ownership error in GNATprove
Related show

Commit Message

Pierre-Marie de Rodat Aug. 14, 2019, 9:53 a.m. UTC
Like Is_Path_Expression, function Is_Subpath_Expression should consider
the possibility that the subpath is a type conversion or type
qualification over the actual subpath node. This avoids spurious
ownership errors in GNATprove.

There is no impact on compilation.

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

2019-08-14  Yannick Moy  <moy@adacore.com>

gcc/ada/

	* sem_spark.adb (Is_Subpath_Expression): Take into account
	conversion and qualification.

Patch
diff mbox series

--- gcc/ada/sem_spark.adb
+++ gcc/ada/sem_spark.adb
@@ -4266,6 +4266,12 @@  package body Sem_SPARK is
    is
    begin
       return Is_Path_Expression (Expr, Is_Traversal)
+
+        or else (Nkind_In (Expr, N_Qualified_Expression,
+                                 N_Type_Conversion,
+                                 N_Unchecked_Type_Conversion)
+                  and then Is_Subpath_Expression (Expression (Expr)))
+
         or else (Nkind (Expr) = N_Attribute_Reference
                   and then
                     (Get_Attribute_Id (Attribute_Name (Expr)) =
@@ -4276,7 +4282,8 @@  package body Sem_SPARK is
                      or else
                      Get_Attribute_Id (Attribute_Name (Expr)) =
                        Attribute_Image))
-       or else Nkind (Expr) = N_Op_Concat;
+
+        or else Nkind (Expr) = N_Op_Concat;
    end Is_Subpath_Expression;
 
    ---------------------------