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] |
In Ada 2005, several constructs of a limited type can be built in place, and as such can be returned by function calls. In Ada 2012, the new expression forms conditional expressions and case expressions can also be built in place if each of their dependent expressions can be built in place. The following must compile and execute quietly: --- procedure Lim is type T is limited record Value : Integer; end record; function Build (X : integer) return T is begin return (if X > 10 then (Value => X / 2) else (Value => 0)); end; THing : T := Build (12); function Build2 (X : Integer) return T is begin return (case X is when 1..10 => (value => 2 * X), when others => (Value => 0)); end; Thing2 : T := Build2 (9); begin if THing.Value /= 6 then raise Program_Error; end if; if THing2.Value /= 18 then raise Program_Error; end if; end; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-10-13 Ed Schonberg <schonberg@adacore.com> * sem_ch3.adb (OK_For_Limited_Init_In_05): Conditional and case expressions are legal limited return values if each one of their dependent expressions are legal.
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] |