From: Hristian Kirtchev Date: Thu, 11 Jul 2019 08:01:49 +0000 (+0000) Subject: [Ada] Link error due to negated intrinsic comparison X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dd8b4c118e15b03a9f8ca748be0c3415e8df788a;p=gcc.git [Ada] Link error due to negated intrinsic comparison This patch corrects the resolution of operator "not" when the expression being negated is an equality operator to prevent the transformation of an intrinsic equality operator into a function call. 2019-07-11 Hristian Kirtchev gcc/ada/ * sem_res.adb (Resolve_Op_Not): Do not rewrite an equality operator into a function call when the operator is intrinsic. gcc/testsuite/ * gnat.dg/equal9.adb: New testcase. From-SVN: r273385 --- diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 79ee0b11ed4..9d5a50f163f 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,8 @@ +2019-07-11 Hristian Kirtchev + + * sem_res.adb (Resolve_Op_Not): Do not rewrite an equality + operator into a function call when the operator is intrinsic. + 2019-07-11 Thomas Quinot * sem_prag.adb (Analyze_Pragma, case pragma Check): Do not call diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 78cbac09e36..c17b28d2a5e 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -10091,15 +10091,20 @@ package body Sem_Res is declare Opnd : constant Node_Id := Right_Opnd (N); + Op_Id : Entity_Id; + begin if B_Typ = Standard_Boolean and then Nkind_In (Opnd, N_Op_Eq, N_Op_Ne) and then Is_Overloaded (Opnd) then Resolve_Equality_Op (Opnd, B_Typ); + Op_Id := Entity (Opnd); - if Ekind (Entity (Opnd)) = E_Function then - Rewrite_Operator_As_Call (Opnd, Entity (Opnd)); + if Ekind (Op_Id) = E_Function + and then not Is_Intrinsic_Subprogram (Op_Id) + then + Rewrite_Operator_As_Call (Opnd, Op_Id); end if; if not Inside_A_Generic or else Is_Entity_Name (Opnd) then diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 66d1e3ed5be..a761f79f7a2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-07-11 Hristian Kirtchev + + * gnat.dg/equal9.adb: New testcase. + 2019-07-11 Thomas Quinot * gnat.dg/scos1.adb: New testcase. diff --git a/gcc/testsuite/gnat.dg/equal9.adb b/gcc/testsuite/gnat.dg/equal9.adb new file mode 100644 index 00000000000..aa60d5b3895 --- /dev/null +++ b/gcc/testsuite/gnat.dg/equal9.adb @@ -0,0 +1,26 @@ +-- { dg-do run } + +with Ada.Text_IO; use Ada.Text_IO; +with System; use System; + +procedure Equal9 is + Val : Address := Null_Address; +begin + if Val = Null_Address then + Put_Line ("= OK"); + else + raise Program_Error; + end if; + + if Val /= Null_Address then + raise Program_Error; + else + Put_Line ("/= OK"); + end if; + + if not (Val = Null_Address) then + raise Program_Error; + else + Put_Line ("not = OK"); + end if; +end Equal9;