aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/misc.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2019-09-19 08:14:38 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-09-19 08:14:38 +0000
commitbee475e2e059ef30d5dae7eea0cb0e09c97a3f18 (patch)
tree4d735318b500056f3988a82b6713ab7cd426cb4d /gcc/ada/gcc-interface/misc.c
parentd53301c91fe9cfffaa06880ea1e32a9fc9246709 (diff)
downloadgcc-bee475e2e059ef30d5dae7eea0cb0e09c97a3f18.zip
gcc-bee475e2e059ef30d5dae7eea0cb0e09c97a3f18.tar.gz
gcc-bee475e2e059ef30d5dae7eea0cb0e09c97a3f18.tar.bz2
[Ada] Fix copy operation with private discriminated record type
This prevents the object code from reading too many bytes from the source for a copy operation involving a private discriminated record type with default discriminants and generated for the assignment of an aggregate to a variable or the initialization of a constant. The front-end already knows that it needs to convert the operation involving the aggregate into individual assignments if the type of the aggregate has mutable components, but it would not do so if this type is private, which does not change anything for code generation. Running these commands: gnatmake -q p -g -fsanitize=address p On the following sources: with Q; use Q; procedure P is type Rec is record A : T; end record; C : constant Rec := Rec'(A => Default_T); begin null; end; package Q is type T is private; Default_T : constant T; private A : constant := 170; B : constant := 8192; type A_Index is range 1 .. A; type B_Index is range 1 .. B; type A_Array is array (A_Index) of Boolean; type B_Array is array (B_Index) of Boolean; type Data_Type is (A_Type, B_Type); type T (Discriminant : Data_Type := A_Type) is record case Discriminant is when A_Type => Field_A : A_Array; when B_Type => Field_B : B_Array; end case; end record; Default_T : constant T := T'(Discriminant => A_Type, Field_A => (others => True)); end Q; Should execute silently. 2019-09-19 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * exp_aggr.adb (Has_Mutable_Components): Look at the underlying type of components to find out whether they are mutable. From-SVN: r275954
Diffstat (limited to 'gcc/ada/gcc-interface/misc.c')
0 files changed, 0 insertions, 0 deletions