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] |
The attributes of formal discrete types, and of arrays whose indices are formal types, are not static and cannot be constant-folded. The same is true if an index type is derived from a formal type. The check for types derived from formal types was missing, leading to improper static evaluation.. The following must compile and execute quietly: with G1; procedure Q is type Indx is range 1 .. 10; package Inst is new G1 (Indx); use Inst; Obj : R := ((others => 0), 10); begin if not Is_Full (Obj) then raise Program_Error; end if; end; --- generic type Ix is range <>; package G1 is type Iterator is new Ix; type Arr is array (Iterator) of integer; type R is record Nodes : Arr; Count : Positive; end record; function Is_Full (It : R) return Boolean; end G1; --- package body G1 is function Is_Full (It : R) return Boolean is begin return It.Count = It.Nodes'Length; end Is_Full; end G1; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-06-23 Ed Schonberg <schonberg@adacore.com> * sem_attr.adb (Eval_Attribute): If the prefix is an array, the attribute cannot be constant-folded if an index type is a formal type, or is derived from one. * checks.adb (Determine_Range): ditto.
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] |