aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorYannick Moy <moy@adacore.com>2019-07-11 08:01:07 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2019-07-11 08:01:07 +0000
commita34badbdf000e931dfa1a1291cf2739e2c75e68d (patch)
treed677009c2a8e3e15f1b14e9db02eed648b6cd4fe /gcc
parent435a6d9580fa1675537a4d2a3151802a15064d3d (diff)
downloadgcc-a34badbdf000e931dfa1a1291cf2739e2c75e68d.zip
gcc-a34badbdf000e931dfa1a1291cf2739e2c75e68d.tar.gz
gcc-a34badbdf000e931dfa1a1291cf2739e2c75e68d.tar.bz2
[Ada] Avoid spurious warning on wrong order of operator call arguments
GNAT issues a warning under -gnatwa when actuals for a call are named like the formals, but in a different order. This is inappropriate for calls to operators in infix form, when e.g. Right <= Left is in general the intended order. Special case calls to operators to avoid that spurious warning. 2019-07-11 Yannick Moy <moy@adacore.com> gcc/ada/ * sem_res.adb (Check_Argument_Order): Special case calls to operators. gcc/testsuite/ * gnat.dg/warn21.adb, gnat.dg/warn21.ads: New testcase. From-SVN: r273378
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/sem_res.adb7
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gnat.dg/warn21.adb6
-rw-r--r--gcc/testsuite/gnat.dg/warn21.ads18
5 files changed, 39 insertions, 1 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 1ebe119..a2316ea 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,8 @@
+2019-07-11 Yannick Moy <moy@adacore.com>
+
+ * sem_res.adb (Check_Argument_Order): Special case calls to
+ operators.
+
2019-07-10 Dmitriy Anisimkov <anisimko@adacore.com>
* libgnat/s-ststop.adb: Remove System.Strings.Stream_Ops
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index db642f0..78cbac0 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -3458,12 +3458,17 @@ package body Sem_Res is
begin
-- Nothing to do if no parameters, or original node is neither a
-- function call nor a procedure call statement (happens in the
- -- operator-transformed-to-function call case), or the call does
+ -- operator-transformed-to-function call case), or the call is to an
+ -- operator symbol (which is usually in infix form), or the call does
-- not come from source, or this warning is off.
if not Warn_On_Parameter_Order
or else No (Parameter_Associations (N))
or else Nkind (Original_Node (N)) not in N_Subprogram_Call
+ or else (Nkind (Name (N)) = N_Identifier
+ and then Present (Entity (Name (N)))
+ and then Nkind (Entity (Name (N)))
+ = N_Defining_Operator_Symbol)
or else not Comes_From_Source (N)
then
return;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index efebc72..24ecc21 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2019-07-11 Yannick Moy <moy@adacore.com>
+
+ * gnat.dg/warn21.adb, gnat.dg/warn21.ads: New testcase.
+
2019-07-11 Richard Biener <rguenther@suse.de>
PR middle-end/91131
diff --git a/gcc/testsuite/gnat.dg/warn21.adb b/gcc/testsuite/gnat.dg/warn21.adb
new file mode 100644
index 0000000..123dfdc
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/warn21.adb
@@ -0,0 +1,6 @@
+-- { dg-do compile }
+-- { dg-options "-gnata -gnatwa" }
+
+package body Warn21 is
+ procedure Foo is null;
+end Warn21;
diff --git a/gcc/testsuite/gnat.dg/warn21.ads b/gcc/testsuite/gnat.dg/warn21.ads
new file mode 100644
index 0000000..a091467
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/warn21.ads
@@ -0,0 +1,18 @@
+package Warn21 is
+
+ type Set is new Integer;
+
+ function "<=" (Left : Set; Right : Set) return Boolean;
+
+ function "=" (Left : Set; Right : Set) return Boolean with
+ Post => "="'Result = (Left <= Right and Right <= Left);
+
+ procedure Foo;
+
+private
+
+ function "<=" (Left : Set; Right : Set) return Boolean is (True);
+ function "=" (Left : Set; Right : Set) return Boolean is
+ (Left <= Right and Right <= Left);
+
+end Warn21;