https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104482

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Kewen Lin <li...@gcc.gnu.org>:

https://gcc.gnu.org/g:38db48346cc045ed5656233c42d01d6d06bffc35

commit r13-2643-g38db48346cc045ed5656233c42d01d6d06bffc35
Author: Kewen Lin <li...@linux.ibm.com>
Date:   Tue Sep 13 04:14:23 2022 -0500

    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.

Reply via email to