r256524 - in /trunk/gcc/ada: ChangeLog exp_ch3.adb

pmderodat@gcc.gnu.org pmderodat@gcc.gnu.org
Thu Jan 11 08:56:00 GMT 2018


Author: pmderodat
Date: Thu Jan 11 08:56:18 2018
New Revision: 256524

URL: https://gcc.gnu.org/viewcvs?rev=256524&root=gcc&view=rev
Log:
[Ada] Warning on out-of-range value for default-initialized scalar object

When an object of a type with a specified Default_Value aspect is
declared without an explicit initial value and the default value is
out of range of the objects subtype, the compiler now issues a warning
that Constraint_Error will be raised due to an out-of-range value.

The test below must output a compiler warning as follows:

$ gcc -c -gnatj70 default_warning.adb
default_warning.adb:7:08: warning: value not in range of type
                          "Subint" defined at line 5,
                          "Constraint_Error" will be raised at run
                          time

procedure Default_Warning is

   type Int_With_Default is new Integer with Default_Value => 0;

   subtype Subint is Int_With_Default range 1 .. 100;

   S : Subint;

begin
   null;
end Default_Warning;

2018-01-11  Gary Dismukes  <dismukes@adacore.com>

gcc/ada/

	* exp_ch3.adb (Default_Initialize_Object): Call New_Copy_Tree on the
	result of Get_Simple_Init_Value and pass the source location of the
	object declaration's object_definition.

Modified:
    trunk/gcc/ada/ChangeLog
    trunk/gcc/ada/exp_ch3.adb



More information about the Gcc-cvs mailing list