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] |
AI05-0103 requires that for elementary types and for constrained types, the subtype indication in an extended return statement and the return subtype of the enclosing function must match statically. This patch completes the implementation of this rule for the case of named access types. Compiling proc.adb must be rejected with the following messages: proc.adb:4:17: subtype must statically match function result subtype proc.adb:13:17: subtype must statically match function result subtype proc.adb:22:21: subtype must statically match function result subtype --- procedure Proc is function F1 return Integer is begin return X : Natural do -- ERROR X := 17; end return; end F1; type Acc_String is access String; function F2 return Acc_String is begin return X : Acc_String(1..10) do -- ERROR X := new String'("0123456789"); end return; end F2; type An_Access is access String; function Nice return not null An_Access is begin return Obj : An_Access do -- ERROR Obj := null; end return; end Nice; begin if F1 /= 17 then raise Program_Error; end if; end; Tested on x86_64-pc-linux-gnu, committed on trunk 2010-10-08 Ed Schonberg <schonberg@adacore.com> * sem_ch6.adb (Check_Return_Subtype): The subtype indication in an extended return must match statically the return subtype of the enclosing function if the type is an elementary type or if it is constrained.
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] |