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]

[Ada] Extend efficient array reset to all elementary types


This change extends the efficient handling of an array reset to 0 by means
of an aggregate with a single Others choice from a discrete component type
to any elementary type.

The 3 instances of the Reset procedure below must invoke memset:

with G;

package P is

  subtype Index is Positive range 1 .. 128;

  type Ptr is access all Integer;

  package My_G_I is new G (Index, Integer, 0);

  package My_G_F is new G (Index, Float, 0.0);

  package My_G_P is new G (Index, Ptr, null);

end P;

generic

  type Header_Num is range <>;

  type Element is private;

  Null_Element : Element;

package G is

  procedure Reset;

end G;

package body G is

  Table : array (Header_Num) of Element;

  procedure Reset is
  begin
    Table := (others => Null_Element);
  end;
  
end G;

Tested on x86_64-pc-linux-gnu, committed on trunk

2017-09-08  Eric Botcazou  <ebotcazou@adacore.com>

	* exp_aggr.adb: Add with & use clause for Urealp.
	(Aggr_Assignment_OK_For_Backend): Accept (almost all)
	elementary types instead of just discrete types.
	* sem_eval.adb (Expr_Value): Deal with N_Null for access types.
	* gcc-interface/trans.c (gnat_to_gnu) <N_Assignment_Statement>:
	Be prepared for the FP zero value in the memset case.  Add small
	guard.

Attachment: difs
Description: Text document


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