Commit b25e5572 by Marek Polacek Committed by Marek Polacek

re PR tree-optimization/84228 (Bogus -Wstringop-truncation warning with -g)

	PR tree-optimization/84228
	* tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Skip debug statements.

	* c-c++-common/Wstringop-truncation-3.c: New test.

From-SVN: r257411
parent d10ac880
2018-02-06 Marek Polacek <polacek@redhat.com>
PR tree-optimization/84228
* tree-ssa-strlen.c (maybe_diag_stxncpy_trunc): Skip debug statements.
2018-02-06 Tamar Christina <tamar.christina@arm.com> 2018-02-06 Tamar Christina <tamar.christina@arm.com>
PR target/82641 PR target/82641
......
2018-02-06 Marek Polacek <polacek@redhat.com>
PR tree-optimization/84228
* c-c++-common/Wstringop-truncation-3.c: New test.
2018-02-06 Tamar Christina <tamar.christina@arm.com> 2018-02-06 Tamar Christina <tamar.christina@arm.com>
PR target/82641 PR target/82641
......
/* PR tree-optimization/84228 */
/* { dg-do compile } */
/* { dg-options "-Wstringop-truncation -O2 -g" } */
char *strncpy (char *, const char *, __SIZE_TYPE__);
struct S
{
char arr[64];
};
int
foo (struct S *p1, const char *a)
{
int b = 5, c = 6, d = 7;
if (a)
goto err;
strncpy (p1->arr, a, sizeof p1->arr); /* { dg-bogus "specified bound" } */
b = 8; c = 9; d = 10;
p1->arr[3] = '\0';
err:
return 0;
}
...@@ -1849,7 +1849,7 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt) ...@@ -1849,7 +1849,7 @@ maybe_diag_stxncpy_trunc (gimple_stmt_iterator gsi, tree src, tree cnt)
/* Look for dst[i] = '\0'; after the stxncpy() call and if found /* Look for dst[i] = '\0'; after the stxncpy() call and if found
avoid the truncation warning. */ avoid the truncation warning. */
gsi_next (&gsi); gsi_next_nondebug (&gsi);
gimple *next_stmt = gsi_stmt (gsi); gimple *next_stmt = gsi_stmt (gsi);
if (!gsi_end_p (gsi) && is_gimple_assign (next_stmt)) if (!gsi_end_p (gsi) && is_gimple_assign (next_stmt))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment