From: Martin Sebor Date: Mon, 2 Mar 2020 18:49:01 +0000 (-0700) Subject: Add new test for PR tree-optimization/92982. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f26688fbe441375e907f0dd2f35837681870b1f4;p=gcc.git Add new test for PR tree-optimization/92982. gcc/testsuite/ChangeLog: PR tree-optimization/92982 * gcc.dg/strlenopt-94.c: New test. --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 79fe37d5a17..e18c6a9f7a6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2020-03-02 Martin Sebor + + PR tree-optimization/92982 + * gcc.dg/strlenopt-94.c: New test. + 2020-03-02 Iain Sandoe * g++.dg/coroutines/torture/func-params-09-awaitable-parms.C: New test. diff --git a/gcc/testsuite/gcc.dg/strlenopt-94.c b/gcc/testsuite/gcc.dg/strlenopt-94.c new file mode 100644 index 00000000000..c2a23d35881 --- /dev/null +++ b/gcc/testsuite/gcc.dg/strlenopt-94.c @@ -0,0 +1,28 @@ +/* PR tree-optimization/93982 - Assignment incorrectly omitted by + -foptimize-strlen + { dg-do run } + { dg-options "-O2 -Wall" } */ + +struct A { const char **a; }; +const char *buf[5]; + +__attribute__((noipa)) struct A +foo (char *p) +{ + struct A r = { (const char **) p }; + r.a[0] = "12345678"; + r.a[1] = ""; + r.a[2] = ""; + r.a[3] = ""; + r.a[4] = ""; + return r; +} + +int +main () +{ + struct A r = foo ((char *) &buf[0]); + if (!r.a[1] || r.a[1][0] != '\0') + __builtin_abort (); + return 0; +}