|
1 | 1 | with Namet; use Namet;
|
2 | 2 | with Nlists; use Nlists;
|
3 | 3 | with Sem;
|
| 4 | +with Sem_Eval; use Sem_Eval; |
4 | 5 | with Sem_Util; use Sem_Util;
|
5 | 6 | with Sem_Aux; use Sem_Aux;
|
6 | 7 | with Snames; use Snames;
|
@@ -4644,51 +4645,70 @@ package body Tree_Walk is
|
4644 | 4645 | procedure Handle_Representation_Clause (N : Node_Id);
|
4645 | 4646 | procedure Handle_Representation_Clause (N : Node_Id) is
|
4646 | 4647 | Attr_Id : constant String := Get_Name_String (Chars (N));
|
4647 |
| - Target_Name : constant Irep := Do_Identifier (Name (N)); |
4648 |
| - Entity_Esize : constant Uint := Esize (Entity (N)); |
4649 |
| - Target_Type_Irep : constant Irep := |
4650 |
| - Follow_Symbol_Type (Get_Type (Target_Name), Global_Symbol_Table); |
4651 |
| - Expression_Value : constant Uint := Intval (Expression (N)); |
4652 | 4648 | begin
|
4653 |
| - pragma Assert (Kind (Target_Type_Irep) in Class_Type); |
4654 |
| - if Attr_Id = "size" then |
4655 |
| - |
4656 |
| - -- Just check that the front-end already applied this size |
4657 |
| - -- clause, i .e. that the size of type-irep we already had |
4658 |
| - -- equals the entity type this clause is applied to (and the |
4659 |
| - -- size specified in this clause). |
4660 |
| - pragma Assert (Entity_Esize = |
4661 |
| - UI_From_Int (Int (Get_Width (Target_Type_Irep))) |
4662 |
| - and Entity_Esize = Expression_Value); |
| 4649 | + -- First check if it is an address clause which gnat2goto does not |
| 4650 | + -- currently handle |
| 4651 | + if Attr_Id = "address" then |
| 4652 | + Report_Unhandled_Node_Empty |
| 4653 | + (N, "Process_Declaration", |
| 4654 | + "Address representation clauses are not currently supported"); |
4663 | 4655 | return;
|
4664 |
| - elsif Attr_Id = "component_size" then |
4665 |
| - if not Is_Array_Type (Entity (N)) then |
4666 |
| - Report_Unhandled_Node_Empty (N, "Process_Declaration", |
4667 |
| - "Component size only supported for array types"); |
4668 |
| - return; |
4669 |
| - end if; |
| 4656 | + elsif Attr_Id = "size" or else Attr_Id = "component_size" then |
4670 | 4657 | declare
|
4671 |
| - Array_Data : constant Irep := |
4672 |
| - Get_Data_Component_From_Type (Target_Type_Irep); |
4673 |
| - Target_Subtype : constant Irep := |
4674 |
| - Follow_Symbol_Type (Get_Subtype (Get_Type (Array_Data)), |
4675 |
| - Global_Symbol_Table); |
4676 |
| - Target_Subtype_Width : constant Uint := |
4677 |
| - UI_From_Int (Int (Get_Width (Target_Subtype))); |
| 4658 | + Target_Name : constant Irep := Do_Identifier (Name (N)); |
| 4659 | + Entity_Esize : constant Uint := Esize (Entity (N)); |
| 4660 | + Target_Type_Irep : constant Irep := |
| 4661 | + Follow_Symbol_Type |
| 4662 | + (Get_Type (Target_Name), Global_Symbol_Table); |
| 4663 | + Expression_Value : constant Uint := Expr_Value (Expression (N)); |
4678 | 4664 | begin
|
4679 |
| - if Component_Size (Entity (N)) /= Expression_Value or |
4680 |
| - Target_Subtype_Width /= Expression_Value |
4681 |
| - then |
4682 |
| - Report_Unhandled_Node_Empty (N, "Process_Declaration", |
4683 |
| - "Having component sizes be different from the size of " & |
4684 |
| - "their underlying type is currently not supported"); |
| 4665 | + pragma Assert (Kind (Target_Type_Irep) in Class_Type); |
| 4666 | + if Attr_Id = "size" then |
| 4667 | + |
| 4668 | + -- Just check that the front-end already applied this size |
| 4669 | + -- clause, i .e. that the size of type-irep we already had |
| 4670 | + -- equals the entity type this clause is applied to (and the |
| 4671 | + -- size specified in this clause). |
| 4672 | + pragma Assert |
| 4673 | + (Entity_Esize = |
| 4674 | + UI_From_Int (Int (Get_Width (Target_Type_Irep))) |
| 4675 | + and Entity_Esize = Expression_Value); |
| 4676 | + return; |
| 4677 | + elsif Attr_Id = "component_size" then |
| 4678 | + if not Is_Array_Type (Entity (N)) then |
| 4679 | + Report_Unhandled_Node_Empty |
| 4680 | + (N, "Process_Declaration", |
| 4681 | + "Component size only supported for array types"); |
| 4682 | + return; |
| 4683 | + end if; |
| 4684 | + declare |
| 4685 | + Array_Data : constant Irep := |
| 4686 | + Get_Data_Component_From_Type (Target_Type_Irep); |
| 4687 | + Target_Subtype : constant Irep := |
| 4688 | + Follow_Symbol_Type (Get_Subtype (Get_Type (Array_Data)), |
| 4689 | + Global_Symbol_Table); |
| 4690 | + Target_Subtype_Width : constant Uint := |
| 4691 | + UI_From_Int (Int (Get_Width (Target_Subtype))); |
| 4692 | + begin |
| 4693 | + if Component_Size (Entity (N)) /= Expression_Value or |
| 4694 | + Target_Subtype_Width /= Expression_Value |
| 4695 | + then |
| 4696 | + Report_Unhandled_Node_Empty |
| 4697 | + (N, "Process_Declaration", |
| 4698 | + "Having component sizes be different from the " |
| 4699 | + & "size of their underlying type " |
| 4700 | + & "is currently not supported"); |
| 4701 | + end if; |
| 4702 | + end; |
| 4703 | + return; |
4685 | 4704 | end if;
|
4686 | 4705 | end;
|
4687 |
| - return; |
4688 | 4706 | end if;
|
4689 | 4707 |
|
4690 |
| - Report_Unhandled_Node_Empty (N, "Process_Declaration", |
4691 |
| - "Representation clause unsupported: " & Attr_Id); |
| 4708 | + Report_Unhandled_Node_Empty |
| 4709 | + (N, "Process_Declaration", |
| 4710 | + "Representation clause unsupported: " & Attr_Id); |
| 4711 | + |
4692 | 4712 | end Handle_Representation_Clause;
|
4693 | 4713 |
|
4694 | 4714 | begin
|
|
0 commit comments