]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: tree-object-size.c (pass_through_call): Do not handle BUILT_IN_STPNCPY_CHK...
authorJakub Jelinek <jakub@redhat.com>
Mon, 25 Jun 2018 16:53:57 +0000 (18:53 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 25 Jun 2018 16:53:57 +0000 (18:53 +0200)
Backported from mainline
2017-11-24  Jakub Jelinek  <jakub@redhat.com>

* tree-object-size.c (pass_through_call): Do not handle
BUILT_IN_STPNCPY_CHK which is not a pass through call.

* gcc.dg/builtin-object-size-18.c: New test.

From-SVN: r262037

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/builtin-object-size-18.c [new file with mode: 0644]
gcc/tree-object-size.c

index 207df787ac7b94472afa2c46c71f5bfabfeeb3e6..1bf9540d50b3b3a49624bde42cf2a5e84ce7ea88 100644 (file)
@@ -1,6 +1,11 @@
 2018-06-25  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-11-24  Jakub Jelinek  <jakub@redhat.com>
+
+       * tree-object-size.c (pass_through_call): Do not handle
+       BUILT_IN_STPNCPY_CHK which is not a pass through call.
+
        2017-11-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/82253
index 65dde4ec2a8ca35cf47512721fa5458f11df6337..10146f45ea0a67bbeae752f64449001ee08ca492 100644 (file)
@@ -1,6 +1,10 @@
 2018-06-25  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-11-24  Jakub Jelinek  <jakub@redhat.com>
+
+       * gcc.dg/builtin-object-size-18.c: New test.
+
        2017-11-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/82253
diff --git a/gcc/testsuite/gcc.dg/builtin-object-size-18.c b/gcc/testsuite/gcc.dg/builtin-object-size-18.c
new file mode 100644 (file)
index 0000000..e065393
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* __stpncpy_chk could return buf up to buf + 64, so
+   the minimum object size might be far smaller than 64.  */
+/* { dg-final { scan-tree-dump-not "return 64;" "optimized" } } */
+
+typedef __SIZE_TYPE__ size_t;
+
+size_t
+foo (const char *p, size_t s, size_t t)
+{
+  char buf[64];
+  char *q = __builtin___stpncpy_chk (buf, p, s, t);
+  return __builtin_object_size (q, 2);
+}
index e683861a12207e03e466a940cd47dc51492d0d6e..af7d6f7064e982d0d74a400caa9e1c48317b8081 100644 (file)
@@ -469,7 +469,6 @@ pass_through_call (const gcall *call)
       case BUILT_IN_MEMSET_CHK:
       case BUILT_IN_STRCPY_CHK:
       case BUILT_IN_STRNCPY_CHK:
-      case BUILT_IN_STPNCPY_CHK:
       case BUILT_IN_STRCAT_CHK:
       case BUILT_IN_STRNCAT_CHK:
       case BUILT_IN_ASSUME_ALIGNED: