From: Richard Sandiford Date: Wed, 20 Dec 2017 12:50:35 +0000 (+0000) Subject: Fix multiple_p for two non-poly_ints X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=27d229f709a928adc7c4e464509cc1633d127f3f;p=gcc.git Fix multiple_p for two non-poly_ints 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 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. From-SVN: r255860 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2a445809a9b..fae3d381272 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2017-12-20 Richard Sandiford + + * poly-int.h (multiple_p): Fix handling of two non-poly_ints. + 2017-12-20 Kyrylo Tkachov * doc/invoke.texi (ARM Options): Document accepted extension options diff --git a/gcc/poly-int.h b/gcc/poly-int.h index 68788d7ddf4..d91244bc469 100644 --- a/gcc/poly-int.h +++ b/gcc/poly-int.h @@ -2027,7 +2027,7 @@ template inline typename if_nonpoly2::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. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c9a03a671db..76f1b795c63 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2017-12-20 Richard Sandiford + + * gcc.dg/plugin/poly-int-tests.h (test_nonpoly_multiple_p): New + function. + (test_nonpoly_type): Call it. + 2017-12-20 Jakub Jelinek PR c++/83490 diff --git a/gcc/testsuite/gcc.dg/plugin/poly-int-tests.h b/gcc/testsuite/gcc.dg/plugin/poly-int-tests.h index b195f67aaf4..4fb32cda3e7 100644 --- a/gcc/testsuite/gcc.dg/plugin/poly-int-tests.h +++ b/gcc/testsuite/gcc.dg/plugin/poly-int-tests.h @@ -4505,6 +4505,19 @@ test_uhwi () wi::uhwi (210, 16))); } +/* Test multiple_p for non-polynomial T. */ + +template +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 @@ -4523,6 +4536,7 @@ template static void test_nonpoly_type () { + test_nonpoly_multiple_p (); test_nonpoly_known_size_p (); }