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  <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.

From-SVN: r255860
This commit is contained in:
Richard Sandiford 2017-12-20 12:50:35 +00:00 committed by Richard Sandiford
parent f4dd468f53
commit 27d229f709
4 changed files with 25 additions and 1 deletions

View 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

View 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. */

View 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

View 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> ();
}