]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR sanitizer/80168 (ICE in make_decl_rtl, at varasm.c:1311 w/ VLA and...
authorJakub Jelinek <jakub@redhat.com>
Tue, 30 May 2017 08:20:45 +0000 (10:20 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 30 May 2017 08:20:45 +0000 (10:20 +0200)
Backported from mainline
2017-03-27  Jakub Jelinek  <jakub@redhat.com>

PR sanitizer/80168
* asan.c (instrument_derefs): Copy over last operand from
original COMPONENT_REF to the new COMPONENT_REF with
DECL_BIT_FIELD_REPRESENTATIVE.
* ubsan.c (instrument_object_size): Likewise.

* gcc.dg/asan/pr80168.c: New test.

From-SVN: r248665

gcc/ChangeLog
gcc/asan.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/asan/pr80168.c [new file with mode: 0644]
gcc/ubsan.c

index 106c41c0501433861fb54758e900346ccb46c66e..aa1439a102ac0effa172af1d04ba27a06fe334bf 100644 (file)
@@ -1,6 +1,14 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-03-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/80168
+       * asan.c (instrument_derefs): Copy over last operand from
+       original COMPONENT_REF to the new COMPONENT_REF with
+       DECL_BIT_FIELD_REPRESENTATIVE.
+       * ubsan.c (instrument_object_size): Likewise.
+
        2017-03-24  Jakub Jelinek  <jakub@redhat.com>
 
        PR rtl-optimization/80112
index dbf392edd3663c865c16488572e82f530b81f19a..8e359681fc434c7073743f65463183407dcde25d 100644 (file)
@@ -1793,7 +1793,8 @@ instrument_derefs (gimple_stmt_iterator *iter, tree t,
       tree repr = DECL_BIT_FIELD_REPRESENTATIVE (TREE_OPERAND (t, 1));
       instrument_derefs (iter, build3 (COMPONENT_REF, TREE_TYPE (repr),
                                       TREE_OPERAND (t, 0), repr,
-                                      NULL_TREE), location, is_store);
+                                      TREE_OPERAND (t, 2)),
+                        location, is_store);
       return;
     }
 
index 44a06cdd1f9b6233fb663171809f3c8b730f647d..90df00b48ca753e24d1504cde138b0a0cefc9079 100644 (file)
@@ -1,6 +1,11 @@
 2017-05-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2017-03-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/80168
+       * gcc.dg/asan/pr80168.c: New test.
+
        2017-03-24  Jakub Jelinek  <jakub@redhat.com>
 
        PR rtl-optimization/80112
diff --git a/gcc/testsuite/gcc.dg/asan/pr80168.c b/gcc/testsuite/gcc.dg/asan/pr80168.c
new file mode 100644 (file)
index 0000000..de23345
--- /dev/null
@@ -0,0 +1,12 @@
+/* PR sanitizer/80168 */
+/* { dg-do compile } */
+
+int a;
+
+int
+foo (void)
+{
+  struct S { int c[a]; int q : 8; int e : 4; } f;
+  f.e = 4;
+  return f.e;
+}
index d471afc0334ddeb87044cb3b3fbf81154fd2daf3..570d1b4b5f6c90ba3808d6d8b99f3519d5070f68 100644 (file)
@@ -1774,7 +1774,7 @@ instrument_object_size (gimple_stmt_iterator *gsi, bool is_lhs)
        {
          tree repr = DECL_BIT_FIELD_REPRESENTATIVE (TREE_OPERAND (t, 1));
          t = build3 (COMPONENT_REF, TREE_TYPE (repr), TREE_OPERAND (t, 0),
-                     repr, NULL_TREE);
+                     repr, TREE_OPERAND (t, 2));
        }
       break;
     case ARRAY_REF: