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

--- Comment #14 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Qing Zhao <qinz...@gcc.gnu.org>:

https://gcc.gnu.org/g:afe6cea4489846aa8585f3c045d16cdaa08cc6cd

commit r13-6379-gafe6cea4489846aa8585f3c045d16cdaa08cc6cd
Author: Qing Zhao <qing.z...@oracle.com>
Date:   Tue Feb 28 17:11:05 2023 +0000

    Fixing PR107411

    This is a bug in tree-ssa-uninit.cc.
    When doing the following:

      /* Ignore the call to .DEFERRED_INIT that define the original
         var itself as the following case:
           temp = .DEFERRED_INIT (4, 2, âalt_reloc");
           alt_reloc = temp;
         In order to avoid generating warning for the fake usage
         at alt_reloc = temp.
      */

    We need to compare the var name inside the .DEFERRED_INIT call
    (the 3rd argument) and the name for the LHS variable. if they are the same,
    we will NOT report the warning.

    There is one issue when we get the name for the LHS variable. when the
    variable doesn't have a DECL_NAME (it's not a user declared variable,
    which is the case for this bug):

      _1 = .DEFERRED_INIT (4, 2, &"D.2389"[0]);
      D.2389 = _1;

    The current checking just ignores this case, and still report the warning.

    The fix is very simple, when getting the name for the LHS variable, we
should
    consider this case and come up with the name the same way as we construct
the
    3rd argument for the call to .DEFERRED_INIT (please refer to the routine
    "gimple_add_init_for_auto_var")

            PR middle-end/107411

    gcc/ChangeLog:

            PR middle-end/107411
            * gimplify.cc (gimple_add_init_for_auto_var): Use sprintf to
replace
            xasprintf.
            * tree-ssa-uninit.cc (warn_uninit): Handle the case when the
            LHS varaible of a .DEFERRED_INIT call doesn't have a DECL_NAME.

    gcc/testsuite/ChangeLog:

            PR middle-end/107411
            * g++.dg/pr107411.C: New test.
  • [Bug middle-end/107411] trivial... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to