This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Add CONSTRUCTOR_NO_CLEARING flag


> in Ada 2012 it is allowed to omit components of aggregates (the equivalent
> of initializers/constructors); in this case, the contents of the
> corresponding fields in the record become undefined.  Now the gimplifier
> implements the C semantics of clearing the missing components, so this
> patch introduces a new flag on constructors to modify that.

My bad, I forgot to install the testcase written by Tristan...

Tested on x86_64-suse-linux, installed on the mainline.


2013-11-12  Tristan Gingold  <gingold@adacore.com>

	* gnat.dg/aggr21.adb: New test.
	* gnat.dg/aggr21_pkg.ad[sb]: New helper.


-- 
Eric Botcazou
-- { dg-do run }

with Aggr21_Pkg; use Aggr21_Pkg;

procedure Aggr21 is
  V : Rec;
begin
  V.A := 12;
  V.S (1 .. 10) := "Hello init";
  V.N := 123;
  Init (V);
  --  Probably not reliable, but the compiler is supposed not to modify V.S
  pragma Assert (V.s (1 .. 5) = "Hello");
end;
package Aggr21_Pkg is

   type Rec is record
      A : Integer;
      S : String (1 .. 120);
      N : Natural;
   end record;

   procedure Init (R : out Rec);

end Aggr21_Pkg;
package body Aggr21_Pkg is

   procedure Init (R : out Rec) is
   begin
      R := (A => 5, S => <>, N => 7);
   end;

end Aggr21_Pkg;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]