re PR sanitizer/80168 (ICE in make_decl_rtl, at varasm.c:1311 w/ VLA and -fsanitize...
authorJakub Jelinek <jakub@redhat.com>
Mon, 27 Mar 2017 08:25:01 +0000 (10:25 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 27 Mar 2017 08:25:01 +0000 (10:25 +0200)
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: r246492

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

index 8dcd897593514a13aa789d8acac5de538f26cb19..f2f40b86c6bc6c6b93ab146a4a734bc6e8f920fa 100644 (file)
@@ -1,3 +1,11 @@
+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-27  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/80170
index a13679d030f339900c3d43213008b9158ff69f86..f1098cbffacea66987a62585850fd4363261d7c4 100644 (file)
@@ -1868,7 +1868,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 0b04afeec541c2e1a149b0b707a080d31cd2e61d..3a8e22e665dfbca93256fb6390a048e8ba68cbeb 100644 (file)
@@ -1,3 +1,8 @@
+2017-03-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/80168
+       * gcc.dg/asan/pr80168.c: New test.
+
 2017-03-27  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/80170
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 17965efde5c0e917da44f34d1d006a1e0c01793c..323c1ccdb4902fa1ce797197099dc1faa2e993c0 100644 (file)
@@ -1772,7 +1772,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: