PR sanitizer/70342
authormpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 6 May 2016 10:50:03 +0000 (10:50 +0000)
committermpolacek <mpolacek@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 6 May 2016 10:50:03 +0000 (10:50 +0000)
* fold-const.c (tree_single_nonzero_warnv_p): For TARGET_EXPR, use
TARGET_EXPR_SLOT as a base.

* g++.dg/ubsan/null-7.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-6-branch@235958 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ubsan/null-7.C [new file with mode: 0644]

index deebffd..e0c4793 100644 (file)
@@ -1,3 +1,13 @@
+2016-05-06  Marek Polacek  <polacek@redhat.com>
+
+       Backported from mainline
+       2016-04-29  Marek Polacek  <polacek@redhat.com>
+                   Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/70342
+       * fold-const.c (tree_single_nonzero_warnv_p): For TARGET_EXPR, use
+       TARGET_EXPR_SLOT as a base.
+
 2016-05-04  Eric Botcazou  <ebotcazou@adacore.com>
 
        * tree-ssa-coalesce.c (gimple_can_coalesce_p): Fix reference in head
index 9514c71..bb4a556 100644 (file)
@@ -13549,6 +13549,9 @@ tree_single_nonzero_warnv_p (tree t, bool *strict_overflow_p)
        if (!DECL_P (base))
          base = get_base_address (base);
 
+       if (base && TREE_CODE (base) == TARGET_EXPR)
+         base = TARGET_EXPR_SLOT (base);
+
        if (!base)
          return false;
 
index df8b560..7c9ba68 100644 (file)
@@ -1,3 +1,11 @@
+2016-05-06  Marek Polacek  <polacek@redhat.com>
+
+       Backported from mainline
+       2016-04-29  Marek Polacek  <polacek@redhat.com>
+
+       PR sanitizer/70342
+       * g++.dg/ubsan/null-7.C: New test.
+
 2016-05-03  Pierre-Marie de Rodat  <derodat@adacore.com>
 
        * gnat.dg/debug5.adb: New testcase.
diff --git a/gcc/testsuite/g++.dg/ubsan/null-7.C b/gcc/testsuite/g++.dg/ubsan/null-7.C
new file mode 100644 (file)
index 0000000..8284bc7
--- /dev/null
@@ -0,0 +1,24 @@
+// PR sanitizer/70342
+// { dg-do compile }
+// { dg-options "-fsanitize=null" }
+
+class A {};
+class B {
+public:
+  B(A);
+};
+class C {
+public:
+  C operator<<(B);
+};
+class D {
+  D(const int &);
+  C m_blackList;
+};
+D::D(const int &) {
+  m_blackList << A() << A() << A() << A() << A() << A() << A() << A() << A()
+              << A() << A() << A() << A() << A() << A() << A() << A() << A()
+              << A() << A() << A() << A() << A() << A() << A() << A() << A()
+              << A() << A() << A() << A() << A() << A() << A() << A() << A()
+              << A() << A() << A() << A() << A() << A() << A() << A() << A();
+}