]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix multiple_p for two non-poly_ints
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Dec 2017 12:50:35 +0000 (12:50 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Dec 2017 12:50:35 +0000 (12:50 +0000)
Fix a stupid inversion.  This function is very rarely used and was
mostly to help split patches up, which is why it didn't get picked
up during initial testing.

2017-12-20  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
* poly-int.h (multiple_p): Fix handling of two non-poly_ints.

gcc/testsuite/
* gcc.dg/plugin/poly-int-tests.h (test_nonpoly_multiple_p): New
function.
(test_nonpoly_type): Call it.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@255860 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/poly-int.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/plugin/poly-int-tests.h

index 2a445809a9b8da58bea0b28896725419033f8d79..fae3d381272fe2a88a251438100a100f656df147 100644 (file)
@@ -1,3 +1,7 @@
+2017-12-20  Richard Sandiford  <richard.sandiford@linaro.org>
+
+       * poly-int.h (multiple_p): Fix handling of two non-poly_ints.
+
 2017-12-20  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * doc/invoke.texi (ARM Options): Document accepted extension options
index 68788d7ddf4521e19cd0b83567c8ce7e8ec67ce3..d91244bc469d5a397dce3b7be6c976974fd3c9cf 100644 (file)
@@ -2027,7 +2027,7 @@ template<typename Ca, typename Cb>
 inline typename if_nonpoly2<Ca, Cb, bool>::type
 multiple_p (Ca a, Cb b)
 {
-  return a % b != 0;
+  return a % b == 0;
 }
 
 /* Return true if A is a (polynomial) multiple of B.  */
index c9a03a671db3249acb06dc2428fd2ac4cdbd2e42..76f1b795c638217e69a8ad4a44352d1f925a0d0d 100644 (file)
@@ -1,3 +1,9 @@
+2017-12-20  Richard Sandiford  <richard.sandiford@linaro.org>
+
+       * gcc.dg/plugin/poly-int-tests.h (test_nonpoly_multiple_p): New
+       function.
+       (test_nonpoly_type): Call it.
+
 2017-12-20  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/83490
index b195f67aaf41a8661404b397360eb9fb74069ddb..4fb32cda3e7af183190d77c23a273750f035b8a7 100644 (file)
@@ -4505,6 +4505,19 @@ test_uhwi ()
                                   wi::uhwi (210, 16)));
 }
 
+/* Test multiple_p for non-polynomial T.  */
+
+template<typename T>
+static void
+test_nonpoly_multiple_p ()
+{
+  ASSERT_TRUE (multiple_p (T (6), T (2)));
+  ASSERT_TRUE (multiple_p (T (6), T (3)));
+  ASSERT_FALSE (multiple_p (T (6), T (4)));
+  ASSERT_FALSE (multiple_p (T (7), T (4)));
+  ASSERT_TRUE (multiple_p (T (8), T (4)));
+}
+
 /* Test known_size_p for non-polynomial T.  */
 
 template<typename T>
@@ -4523,6 +4536,7 @@ template<typename T>
 static void
 test_nonpoly_type ()
 {
+  test_nonpoly_multiple_p<T> ();
   test_nonpoly_known_size_p<T> ();
 }