aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2018-10-09 15:06:55 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2018-10-09 15:06:55 +0000
commitc743425fce5517242dd67761fea298cd3459b4cc (patch)
tree8681015a93c746718344e21e388debb458823320 /libcpp
parent4b9e1bc78110d65377acdf23ee3733f8c69baef9 (diff)
downloadgcc-c743425fce5517242dd67761fea298cd3459b4cc.zip
gcc-c743425fce5517242dd67761fea298cd3459b4cc.tar.gz
gcc-c743425fce5517242dd67761fea298cd3459b4cc.tar.bz2
[Ada] Fix spurious -Wuninitialized warnings for small records
This change is aimed at getting rid of spurious -Wuninitialized warnings issued for small records passed by copy and containing default values for some of their components. The source of the problem is that the _Init parameter of the initialization routine is declared as an in/out parameter, so the uninitialized object is passed by copy to it and this can be flagged by -Wuninitialized. That's why the mode of the parameter is changed to out, except for the cases where information really needs to be passed in: unconstrained array types, protected and task types. For the following record type Rec! type Rec is record B : Boolean := True; end record; the initialization routine must now be: procedure r__recIP (_init : out r__rec1) is begin _init.b := true; return; end r__recIP; 2018-10-09 Eric Botcazou <ebotcazou@adacore.com> gcc/ada/ * exp_ch3.adb (Is_Null_Statement_List): New predicate. (Build_Array_Init_Proc): Use it to find out whether the initialization procedure Is_Null_Init_Proc; if so, set Warnings_Off on the parameter. (Build_Init_Procedure): Likewise. (Init_Formals): Use an in/out first parameter only for unconstrained arrays and for records either containing or built for proteced types or task types; use an out parameter in all the other cases. * fe.h (Is_Init_Proc): Declare. * gcc-interface/decl.c (type_requires_init_of_formal): Do not return true for a discriminant in an unchecked union. (gnat_to_gnu_param): Do not create a PARM_DECL for the Out parameter of an initialization procedure. From-SVN: r264984
Diffstat (limited to 'libcpp')
0 files changed, 0 insertions, 0 deletions