From: Martin Sebor Date: Fri, 28 Dec 2018 19:26:14 +0000 (+0000) Subject: tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Avoid undesirable warning. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3a03bffd4873ae4efa21c360cc6d147fee7365a7;p=gcc.git tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Avoid undesirable warning. * tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Avoid undesirable warning. From-SVN: r267454 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 741c02d6cda..e79809c50f6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2018-12-28 Martin Sebor + + * tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Avoid + undesirable warning. + 2018-12-28 Thomas Schwinge * omp-expand.c (expand_omp_target): Restructure OpenACC vs. OpenMP diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c index 669c315dce2..c74ce0feac5 100644 --- a/gcc/tree-ssa-strlen.c +++ b/gcc/tree-ssa-strlen.c @@ -2114,6 +2114,13 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt) if (wi::to_wide (dstsize) != cntrange[1]) return false; + /* Avoid warning for strncpy(a, b, N) calls where the following + equalities hold: + N == sizeof a && N == sizeof b */ + if (tree srcsize = compute_objsize (src, 1)) + if (wi::to_wide (srcsize) == cntrange[1]) + return false; + if (cntrange[0] == cntrange[1]) return warning_at (callloc, OPT_Wstringop_truncation, "%G%qD specified bound %E equals destination size",