[COMMITTED,16/30] ada: exp_pakd.adb: disable packed expansions in CodePeer_Mode

Message ID 20240801151738.400796-16-poulhies@adacore.com
State Committed
Commit 65c88a1a57a81b16c393224b65db8bb2c8a568cf
Headers
Series [COMMITTED,01/30] ada: Remove obsolete workaround |

Commit Message

Marc Poulhiès Aug. 1, 2024, 3:17 p.m. UTC
  From: Ghjuvan Lacambre <lacambre@adacore.com>

A previous commit disabled the removal of the Component_Size aspect from
GNAT's tree when in CodePeer_Mode. This effectively resulted in CodePeer
not ignoring Component_Size anymore. As a side effect, GNAT started
expanding packed operations on array types from their high-level
representations to operations operating on bits. It wasn't caught during
the original testing, but this actually confuses CodePeer. We thus need
to disable expansion of packed operations while in CodePeer_Mode.

gcc/ada/

	* exp_pakd.adb (Expand_Bit_Packed_Element_Set): Disable expansion
	in CodePeerMode.
	(Expand_Packed_Address_Reference): Likewise.
	(Expand_Packed_Bit_Reference): Likewise.
	(Expand_Packed_Boolean_Operator): Likewise.
	(Expand_Packed_Element_Reference): Likewise.
	(Expand_Packed_Eq): Likewise.
	(Expand_Packed_Not): Likewise.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/exp_pakd.adb | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
  

Patch

diff --git a/gcc/ada/exp_pakd.adb b/gcc/ada/exp_pakd.adb
index 59dfe5df8df..00bf60ae406 100644
--- a/gcc/ada/exp_pakd.adb
+++ b/gcc/ada/exp_pakd.adb
@@ -1121,6 +1121,10 @@  package body Exp_Pakd is
    begin
       pragma Assert (Is_Bit_Packed_Array (Etype (Prefix (Lhs))));
 
+      if CodePeer_Mode then
+         return;
+      end if;
+
       Obj := Relocate_Node (Prefix (Lhs));
       Convert_To_Actual_Subtype (Obj);
       Atyp := Etype (Obj);
@@ -1507,6 +1511,11 @@  package body Exp_Pakd is
       Offset : Node_Id;
 
    begin
+
+      if CodePeer_Mode then
+         return;
+      end if;
+
       --  We build an expression that has the form
 
       --    outer_object'Address
@@ -1546,6 +1555,11 @@  package body Exp_Pakd is
       Offset : Node_Id;
 
    begin
+
+      if CodePeer_Mode then
+         return;
+      end if;
+
       --  We build an expression that has the form
 
       --    (linear-subscript * component_size      for each array reference
@@ -1581,6 +1595,11 @@  package body Exp_Pakd is
       PAT  : Entity_Id;
 
    begin
+
+      if CodePeer_Mode then
+         return;
+      end if;
+
       Convert_To_Actual_Subtype (L);
       Convert_To_Actual_Subtype (R);
 
@@ -1744,6 +1763,11 @@  package body Exp_Pakd is
       Arg   : Node_Id;
 
    begin
+
+      if CodePeer_Mode then
+         return;
+      end if;
+
       --  If the node is an actual in a call, the prefix has not been fully
       --  expanded, to account for the additional expansion for in-out actuals
       --  (see expand_actuals for details). If the prefix itself is a packed
@@ -1907,6 +1931,11 @@  package body Exp_Pakd is
       PAT  : Entity_Id;
 
    begin
+
+      if CodePeer_Mode then
+         return;
+      end if;
+
       Convert_To_Actual_Subtype (L);
       Convert_To_Actual_Subtype (R);
       Ltyp := Underlying_Type (Etype (L));
@@ -2004,6 +2033,11 @@  package body Exp_Pakd is
       Size : Unat;
 
    begin
+
+      if CodePeer_Mode then
+         return;
+      end if;
+
       Convert_To_Actual_Subtype (Opnd);
       Rtyp := Etype (Opnd);