diff --git a/gcc/ada/exp_aggr.adb b/gcc/ada/exp_aggr.adb index 4b14043d276..82afcaaa0e8 100644 --- a/gcc/ada/exp_aggr.adb +++ b/gcc/ada/exp_aggr.adb @@ -2026,6 +2026,16 @@ package body Exp_Aggr is end; end if; + -- Set Referenced_As_LHS if appropriate. We are neither interested + -- in compiler-generated aggregates, nor in references outside the + -- extended main source unit. + + if Comes_From_Source (N) + and then In_Extended_Main_Source_Unit (Into) + then + Set_Referenced_Modified (Into, Out_Param => False); + end if; + -- First before we start, a special case. If we have a bit packed -- array represented as a modular type, then clear the value to -- zero first, to ensure that unused bits are properly cleared. diff --git a/gcc/testsuite/gnat.dg/warn36.adb b/gcc/testsuite/gnat.dg/warn36.adb new file mode 100644 index 00000000000..fa3d25e8654 --- /dev/null +++ b/gcc/testsuite/gnat.dg/warn36.adb @@ -0,0 +1,12 @@ +-- { dg-do compile } +-- { dg-options "-gnatwu" } + +procedure Warn36 is + + type Arr is array (1 .. 65) of Integer; + + A : Arr; + +begin + A := (others => 1); +end;