diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-05-02 10:49:55 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2017-05-02 10:49:55 +0200 |
commit | 62d40a7a4e9d8e16149d274f1370bd3024eb2bd5 (patch) | |
tree | 40cf95a701fe611bafde52966581fddd6a101dfc /gcc/ada/checks.adb | |
parent | d86fb53f2099c77d14ce59f2dda30bcfeb1df328 (diff) | |
download | gcc-62d40a7a4e9d8e16149d274f1370bd3024eb2bd5.zip gcc-62d40a7a4e9d8e16149d274f1370bd3024eb2bd5.tar.gz gcc-62d40a7a4e9d8e16149d274f1370bd3024eb2bd5.tar.bz2 |
[multiple changes]
2017-05-02 Eric Botcazou <ebotcazou@adacore.com>
* atree.h (Flag290): Add missing terminating parenthesis.
* einfo.adb (Is_Class_Wide_Clone): Use Flag290.
(Set_Is_Class_Wide_Clone): Likewise.
* einfo.ads (Is_Class_Wide_Clone): Likewise.
2017-05-02 Gary Dismukes <dismukes@adacore.com>
* checks.ads (Null_Exclusion_Static_Checks): Add Boolean
parameter Array_Comp to indicate the case of an array object
with null-excluding components.
* checks.adb (Null_Exclusion_Static_Checks):
Call Compile_Time_Constraint_Error instead of
Apply_Compile_Time_Constraint_Error in the component case. Also
call that when Array_Comp is True, with an appropriate warning for
the array component case. Only create an explicit initialization
by null in the case of an object of a null-excluding access type
(and no longer do that in the component case).
* sem_ch3.adb (Check_Component): Add a Boolean parameter
Array_Comp defaulted to False. Pass Empty for the Comp
actual when calling Null_Exclusion_Static_Checks in the case
where Comp_Decl matches Object_Decl, because we don't have a
component in that case. In the case of an object or component
of an array type, pass True for Array_Comp on the recursive call
to Check_Component.
From-SVN: r247474
Diffstat (limited to 'gcc/ada/checks.adb')
-rw-r--r-- | gcc/ada/checks.adb | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb index e8f38f9..d4a3aa4 100644 --- a/gcc/ada/checks.adb +++ b/gcc/ada/checks.adb @@ -4043,8 +4043,9 @@ package body Checks is ---------------------------------- procedure Null_Exclusion_Static_Checks - (N : Node_Id; - Comp : Node_Id := Empty) + (N : Node_Id; + Comp : Node_Id := Empty; + Array_Comp : Boolean := False) is Error_Node : Node_Id; Expr : Node_Id; @@ -4120,13 +4121,6 @@ package body Checks is and then not Constant_Present (N) and then not No_Initialization (N) then - -- Add an expression that assigns null. This node is needed by - -- Apply_Compile_Time_Constraint_Error, which will replace this with - -- a Constraint_Error node. - - Set_Expression (N, Make_Null (Sloc (N))); - Set_Etype (Expression (N), Etype (Defining_Identifier (N))); - if Present (Comp) then -- Specialize the warning message to indicate that we are dealing @@ -4136,14 +4130,36 @@ package body Checks is Error_Msg_Name_1 := Chars (Defining_Identifier (Comp)); Error_Msg_Name_2 := Chars (Defining_Identifier (N)); - Apply_Compile_Time_Constraint_Error - (N => Expression (N), - Msg => - "(Ada 2005) null-excluding component % of object % must be " - & "initialized??", - Reason => CE_Null_Not_Allowed); + Discard_Node + (Compile_Time_Constraint_Error + (N => N, + Msg => + "(Ada 2005) null-excluding component % of object % must " + & "be initialized??", + Ent => Defining_Identifier (Comp))); + + -- This is a case of an array with null-excluding components, so + -- indicate that in the warning. + + elsif Array_Comp then + Discard_Node + (Compile_Time_Constraint_Error + (N => N, + Msg => + "(Ada 2005) null-excluding array components must " + & "be initialized??", + Ent => Defining_Identifier (N))); + + -- Normal case of object of a null-excluding access type else + -- Add an expression that assigns null. This node is needed by + -- Apply_Compile_Time_Constraint_Error, which will replace this + -- with a Constraint_Error node. + + Set_Expression (N, Make_Null (Sloc (N))); + Set_Etype (Expression (N), Etype (Defining_Identifier (N))); + Apply_Compile_Time_Constraint_Error (N => Expression (N), Msg => |