diff gcc/testsuite/gcc.dg/strlenopt-94.c @ 152:2b5abeee2509

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gcc/testsuite/gcc.dg/strlenopt-94.c	Mon May 25 07:50:57 2020 +0900
@@ -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;
+}