[multiple changes]

2016-04-27  Hristian Kirtchev  <kirtchev@adacore.com>

	* sem_ch3.adb: Minor reformatting.

2016-04-27  Ed Schonberg  <schonberg@adacore.com>

	* sem_dim.adb (Analyze_Dimension, case N_Identifier): Check
	that identifier has a usable type before analysis, to handle
	properly identifiers introduced after some lexical/syntactic
	recovery that created new identifiers.

From-SVN: r235498
This commit is contained in:
Arnaud Charlet 2016-04-27 14:56:41 +02:00
parent db99c46e1d
commit 14f3895c40
3 changed files with 44 additions and 23 deletions

View File

@ -1,3 +1,14 @@
2016-04-27 Hristian Kirtchev <kirtchev@adacore.com>
* sem_ch3.adb: Minor reformatting.
2016-04-27 Ed Schonberg <schonberg@adacore.com>
* sem_dim.adb (Analyze_Dimension, case N_Identifier): Check
that identifier has a usable type before analysis, to handle
properly identifiers introduced after some lexical/syntactic
recovery that created new identifiers.
2016-04-27 Bob Duff <duff@adacore.com> 2016-04-27 Bob Duff <duff@adacore.com>
* a-coinve.adb, a-comutr.adb, a-conhel.adb, a-convec.adb, * a-coinve.adb, a-comutr.adb, a-conhel.adb, a-convec.adb,

View File

@ -13033,15 +13033,13 @@ package body Sem_Ch3 is
Related_Nod : Node_Id; Related_Nod : Node_Id;
For_Access : Boolean := False) For_Access : Boolean := False)
is is
E : Entity_Id := Entity (Subtype_Mark (S)); E : Entity_Id := Entity (Subtype_Mark (S));
T : Entity_Id; T : Entity_Id;
C : Node_Id;
Elist : Elist_Id := New_Elmt_List;
procedure Fixup_Bad_Constraint; procedure Fixup_Bad_Constraint;
-- This is called after finding a bad constraint, and after having -- Called after finding a bad constraint, and after having posted an
-- posted an appropriate error message. The mission is to leave the -- appropriate error message. The goal is to leave type Def_Id in as
-- entity T in as reasonable state as possible. -- reasonable state as possiblet.
-------------------------- --------------------------
-- Fixup_Bad_Constraint -- -- Fixup_Bad_Constraint --
@ -13065,6 +13063,11 @@ package body Sem_Ch3 is
Set_Error_Posted (Def_Id); Set_Error_Posted (Def_Id);
end Fixup_Bad_Constraint; end Fixup_Bad_Constraint;
-- Local variables
C : Node_Id;
Constr : Elist_Id := New_Elmt_List;
-- Start of processing for Constrain_Discriminated_Type -- Start of processing for Constrain_Discriminated_Type
begin begin
@ -13091,27 +13094,27 @@ package body Sem_Ch3 is
and then Present (Full_View (T)) and then Present (Full_View (T))
and then and then
(Has_Unknown_Discriminants (T) (Has_Unknown_Discriminants (T)
or else (not Has_Discriminants (T) or else
and then Has_Discriminants (Full_View (T)) (not Has_Discriminants (T)
and then Present and then Has_Discriminants (Full_View (T))
(Discriminant_Default_Value and then Present (Discriminant_Default_Value
(First_Discriminant (Full_View (T)))))) (First_Discriminant (Full_View (T))))))
then then
T := Full_View (T); T := Full_View (T);
E := Full_View (E); E := Full_View (E);
end if; end if;
-- Ada 2005 (AI-412): Constrained incomplete subtypes are illegal. -- Ada 2005 (AI-412): Constrained incomplete subtypes are illegal. Avoid
-- Avoid generating an error for access-to-incomplete subtypes. -- generating an error for access-to-incomplete subtypes.
if Ada_Version >= Ada_2005 if Ada_Version >= Ada_2005
and then Ekind (T) = E_Incomplete_Type and then Ekind (T) = E_Incomplete_Type
and then Nkind (Parent (S)) = N_Subtype_Declaration and then Nkind (Parent (S)) = N_Subtype_Declaration
and then not Is_Itype (Def_Id) and then not Is_Itype (Def_Id)
then then
-- A little sanity check, emit an error message if the type -- A little sanity check, emit an error message if the type has
-- has discriminants to begin with. Type T may be a regular -- discriminants to begin with. Type T may be a regular incomplete
-- incomplete type or imported via a limited with clause. -- type or imported via a limited with clause.
if Has_Discriminants (T) if Has_Discriminants (T)
or else (From_Limited_With (T) or else (From_Limited_With (T)
@ -13152,23 +13155,23 @@ package body Sem_Ch3 is
return; return;
end if; end if;
-- T may be an unconstrained subtype (e.g. a generic actual). -- T may be an unconstrained subtype (e.g. a generic actual). Constraint
-- Constraint applies to the base type. -- applies to the base type.
T := Base_Type (T); T := Base_Type (T);
Elist := Build_Discriminant_Constraints (T, S); Constr := Build_Discriminant_Constraints (T, S);
-- If the list returned was empty we had an error in building the -- If the list returned was empty we had an error in building the
-- discriminant constraint. We have also already signalled an error -- discriminant constraint. We have also already signalled an error
-- in the incomplete type case -- in the incomplete type case
if Is_Empty_Elmt_List (Elist) then if Is_Empty_Elmt_List (Constr) then
Fixup_Bad_Constraint; Fixup_Bad_Constraint;
return; return;
end if; end if;
Build_Discriminated_Subtype (T, Def_Id, Elist, Related_Nod, For_Access); Build_Discriminated_Subtype (T, Def_Id, Constr, Related_Nod, For_Access);
end Constrain_Discriminated_Type; end Constrain_Discriminated_Type;
--------------------------- ---------------------------

View File

@ -1143,7 +1143,6 @@ package body Sem_Dim is
N_Expanded_Name | N_Expanded_Name |
N_Explicit_Dereference | N_Explicit_Dereference |
N_Function_Call | N_Function_Call |
N_Identifier |
N_Indexed_Component | N_Indexed_Component |
N_Qualified_Expression | N_Qualified_Expression |
N_Selected_Component | N_Selected_Component |
@ -1152,6 +1151,14 @@ package body Sem_Dim is
N_Unchecked_Type_Conversion => N_Unchecked_Type_Conversion =>
Analyze_Dimension_Has_Etype (N); Analyze_Dimension_Has_Etype (N);
-- In the presence of a repaired syntax error, an identifier
-- may be introduced without a usable type.
when N_Identifier =>
if Present (Etype (N)) then
Analyze_Dimension_Has_Etype (N);
end if;
when N_Number_Declaration => when N_Number_Declaration =>
Analyze_Dimension_Number_Declaration (N); Analyze_Dimension_Number_Declaration (N);