Skip to content

Commit db2ffc5

Browse files
Petr Bauchchrisr-diffblue
authored andcommitted
Handle pragma machine attribute
Case by case based on what the attribute is. Attribute signal would probably be ignored by CBMC anyway. And so do we here.
1 parent 78580cc commit db2ffc5

File tree

1 file changed

+36
-2
lines changed

1 file changed

+36
-2
lines changed

gnat2goto/driver/tree_walk.adb

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4762,6 +4762,9 @@ package body Tree_Walk is
47624762

47634763
procedure Process_Pragma_Declaration (N : Node_Id) is
47644764
procedure Handle_Pragma_Volatile (N : Node_Id);
4765+
procedure Handle_Pragma_Machine_Attribute (N : Node_Id)
4766+
with Pre => Nkind (N) in N_Pragma
4767+
and then Pragma_Name (N) = Name_Machine_Attribute;
47654768

47664769
procedure Handle_Pragma_Volatile (N : Node_Id) is
47674770
Argument_Associations : constant List_Id :=
@@ -4783,6 +4786,38 @@ package body Tree_Walk is
47834786
Position => Global_Symbol_Table.Find (Expression_Id),
47844787
Process => Set_Volatile'Access);
47854788
end Handle_Pragma_Volatile;
4789+
4790+
procedure Handle_Pragma_Machine_Attribute (N : Node_Id) is
4791+
Argument_Associations : constant List_Id :=
4792+
Pragma_Argument_Associations (N);
4793+
4794+
-- first is the identifier to be given the attribute
4795+
First_Argument : constant Node_Id := First (Argument_Associations);
4796+
4797+
-- second is the attribute as string
4798+
Second_Argument : constant Node_Id := Next (First_Argument);
4799+
Attr_String_Id : constant String_Id :=
4800+
Strval (Expression (Second_Argument));
4801+
Attr_Length : constant Integer :=
4802+
Integer (String_Length (Attr_String_Id));
4803+
begin
4804+
String_To_Name_Buffer (Attr_String_Id);
4805+
declare
4806+
Attr_String : String
4807+
renames Name_Buffer (1 .. Attr_Length);
4808+
begin
4809+
if Attr_String = "signal" then
4810+
-- CBMC would not acknowledge this one anyway -> Ignored
4811+
null;
4812+
else
4813+
Report_Unhandled_Node_Empty
4814+
(N, "Process_Pragma_Declaration",
4815+
"Unsupported pragma: Machine Attribute "
4816+
& Attr_String);
4817+
end if;
4818+
end;
4819+
end Handle_Pragma_Machine_Attribute;
4820+
47864821
begin
47874822
case Pragma_Name (N) is
47884823
when Name_Assert |
@@ -4948,8 +4983,7 @@ package body Tree_Walk is
49484983
Report_Unhandled_Node_Empty (N, "Process_Pragma_Declaration",
49494984
"Known but unsupported pragma: Linker Options");
49504985
when Name_Machine_Attribute =>
4951-
Report_Unhandled_Node_Empty (N, "Process_Pragma_Declaration",
4952-
"Unsupported pragma: Machine Attribute");
4986+
Handle_Pragma_Machine_Attribute (N);
49534987
when Name_Check =>
49544988
Report_Unhandled_Node_Empty (N, "Process_Pragma_Declaration",
49554989
"Unsupported pragma: Check");

0 commit comments

Comments
 (0)