]> gcc.gnu.org Git - gcc.git/commit
rs6000: Fix the check of bif argument number [PR104482]
authorKewen Lin <linkw@linux.ibm.com>
Tue, 13 Sep 2022 09:14:23 +0000 (04:14 -0500)
committerKewen Lin <linkw@linux.ibm.com>
Wed, 21 Sep 2022 02:31:57 +0000 (21:31 -0500)
commit1a71881d05d3ec3e56492fff0197f88dcf4d9dbc
tree1278782b0e5a7974b230ba0c42126db8bae44d3d
parent104864f99c07f87b53c7f45c50a1991b21249489
rs6000: Fix the check of bif argument number [PR104482]

As PR104482 shown, it's one regression about the handlings when
the argument number is more than the one of built-in function
prototype.  The new bif support only catches the case that the
argument number is less than the one of function prototype, but
it misses the case that the argument number is more than the one
of function prototype.  Because it uses "n != expected_args",
n is updated in

   for (n = 0; !VOID_TYPE_P (TREE_VALUE (fnargs)) && n < nargs;
        fnargs = TREE_CHAIN (fnargs), n++)

, it's restricted to be less than or equal to expected_args with
the guard !VOID_TYPE_P (TREE_VALUE (fnargs)), so it's wrong.

The fix is to use nargs instead, also move the checking hunk's
location ahead to avoid useless further scanning when the counts
mismatch.

PR target/104482

gcc/ChangeLog:

* config/rs6000/rs6000-c.cc (altivec_resolve_overloaded_builtin): Fix
the equality check for argument number, and move this hunk ahead.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr104482.c: New test.

(cherry picked from commit 38db48346cc045ed5656233c42d01d6d06bffc35)
gcc/config/rs6000/rs6000-c.cc
gcc/testsuite/gcc.target/powerpc/pr104482.c [new file with mode: 0644]
This page took 0.063537 seconds and 6 git commands to generate.