[COMMITTED] ada: Fix expanding container aggregates

Message ID 20230627120745.3419192-1-poulhies@adacore.com
State Accepted
Headers
Series [COMMITTED] ada: Fix expanding container aggregates |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Marc Poulhiès June 27, 2023, 12:07 p.m. UTC
  From: Viljar Indus <indus@adacore.com>

Ensure that that container aggregate expressions are expanded as
such and not as records even if the type of the expression is a
record.

gcc/ada/

	* exp_aggr.adb (Expand_N_Aggregate): Ensure that container
	aggregate expressions do not get expanded as records but instead
	as container aggregates.

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

---
 gcc/ada/exp_aggr.adb | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Eric Botcazou July 7, 2023, 8:51 a.m. UTC | #1
> Ensure that that container aggregate expressions are expanded as
> such and not as records even if the type of the expression is a
> record.
> 
> gcc/ada/
> 
> 	* exp_aggr.adb (Expand_N_Aggregate): Ensure that container
> 	aggregate expressions do not get expanded as records but instead
> 	as container aggregates.

This is not a regression but the problem is quite visible in Ada 2022 so I 
backported the fix onto the 13 branch.
  

Patch

diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb
index 5e22fefbc1d..d922c3bf1a4 100644
--- a/gcc/ada/exp_aggr.adb
+++ b/gcc/ada/exp_aggr.adb
@@ -6463,6 +6463,7 @@  package body Exp_Aggr is
 
       if Is_Record_Type (T)
         and then not Is_Private_Type (T)
+        and then not Is_Homogeneous_Aggregate (N)
       then
          Expand_Record_Aggregate (N);