From de83907ada394e5be1343fac4fca5d9b5de3db4f Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Mon, 18 Nov 2019 22:14:16 +0000 Subject: [PATCH] PR middle-end/92493 - ICE in get_origin_and_offset at gimple-ssa-sprintf.c gcc/ChangeLog: PR tree-optimization/92493 * gimple-ssa-sprintf.c (get_origin_and_offset): Remove spurious assignment. gcc/testsuite/ChangeLog: PR tree-optimization/92493 * gcc.dg/pr92493.c: New test. From-SVN: r278423 --- gcc/ChangeLog | 6 ++++++ gcc/gimple-ssa-sprintf.c | 1 - gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/pr92493.c | 29 +++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/pr92493.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0c71cef..11414b2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-11-18 Martin Sebor + + PR tree-optimization/92493 + * gimple-ssa-sprintf.c (get_origin_and_offset): Remove spurious + assignment. + 2019-11-18 Giuliano Belinassi * cfgloop.c (get_loop_body_in_custom_order): New. diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c index f6cd8e9..804a086 100644 --- a/gcc/gimple-ssa-sprintf.c +++ b/gcc/gimple-ssa-sprintf.c @@ -2346,7 +2346,6 @@ get_origin_and_offset (tree x, HOST_WIDE_INT *fldoff, HOST_WIDE_INT *off) { *fldoff += index; *off -= index; - fldoff = NULL; } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 83f704f..199cd05 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-11-18 Martin Sebor + + PR tree-optimization/92493 + * gcc.dg/pr92493.c: New test. + 2019-11-18 Joseph Myers * gcc.dg/c11-attr-syntax-1.c, gcc.dg/c11-attr-syntax-2.c, diff --git a/gcc/testsuite/gcc.dg/pr92493.c b/gcc/testsuite/gcc.dg/pr92493.c new file mode 100644 index 0000000..d301300 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr92493.c @@ -0,0 +1,29 @@ +/* PR middle-end/92493 - ICE in get_origin_and_offset at gimple-ssa-sprintf.c + { dg-do compile } + { dg-options "-O3 -Wall" } */ + +struct A +{ + int i; + char a[2]; +} *p; + +struct B +{ + short j; + struct A a; +} b; + +void warn (int j) +{ + struct A *q = &b.a; + p = q + j; + __builtin_snprintf (p->a, 8, "%s", p->a); // { dg-warning "\\\[-Wrestrict" } +} + +void nowarn (char *d, int j) +{ + struct A *q = &b.a; + p = q + j; + __builtin_snprintf (d, 8, "%s", p->a); +} -- 2.7.4