re PR sanitizer/83987 (ICE with OpenMP, sanitizer and virtual bases)
authorJakub Jelinek <jakub@gcc.gnu.org>
Tue, 23 Jan 2018 20:36:34 +0000 (21:36 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 23 Jan 2018 20:36:34 +0000 (21:36 +0100)
PR sanitizer/83987
* tree.c (cp_free_lang_data): Change DECL_VALUE_EXPR of
DECL_OMP_PRIVATIZED_MEMBER vars to error_mark_node.

* g++.dg/ubsan/pr83987.C: New test.

From-SVN: r256997

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/ubsan/pr83987.C [new file with mode: 0644]

index 97c54ac9a0036e641b168167f028433c9dd828ac..a0a3c13d993591dcd27554a2a521f6f04b63c103 100644 (file)
@@ -1,3 +1,9 @@
+2018-01-23  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/83987
+       * tree.c (cp_free_lang_data): Change DECL_VALUE_EXPR of
+       DECL_OMP_PRIVATIZED_MEMBER vars to error_mark_node.
+
 2018-01-23  Nathan Sidwell  <nathan@acm.org>
 
        PR c++/83988
index ed51c28858f951ec1ca587620e2d4458b94c64bd..e87c59659a5d5e0101dcc8e37a0343d247040629 100644 (file)
@@ -5274,6 +5274,16 @@ cp_free_lang_data (tree t)
     /* We do not need the leftover chaining of namespaces from the
        binding level.  */
     DECL_CHAIN (t) = NULL_TREE;
+  /* Set DECL_VALUE_EXPRs of OpenMP privatized member artificial
+     decls to error_mark_node.  These are DECL_IGNORED_P and after
+     OpenMP lowering they aren't useful anymore.  Clearing DECL_VALUE_EXPR
+     doesn't work, as expansion could then consider them as something
+     to be expanded.  */
+  if (VAR_P (t)
+      && DECL_LANG_SPECIFIC (t)
+      && DECL_OMP_PRIVATIZED_MEMBER (t)
+      && DECL_IGNORED_P (t))
+    SET_DECL_VALUE_EXPR (t, error_mark_node);
 }
 
 /* Stub for c-common.  Please keep in sync with c-decl.c.
index c52b2d96d4f545e31cd84413b56e2a3359c2725a..ce9c3c8e10bd4c6c2f1c607d589127cb47ae2901 100644 (file)
@@ -1,12 +1,17 @@
-2018-23-01  Paul Thomas  <pault@gcc.gnu.org>
+2018-01-23  Jakub Jelinek  <jakub@redhat.com>
+
+       PR sanitizer/83987
+       * g++.dg/ubsan/pr83987.C: New test.
+
+2018-01-23  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/83866
-       * gfortran.dg/pdt_29.f03 : New test.
+       * gfortran.dg/pdt_29.f03: New test.
 
-2018-23-01  Paul Thomas  <pault@gcc.gnu.org>
+2018-01-23  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/83898
-       * gfortran.dg/associate_33.f03 : New test.
+       * gfortran.dg/associate_33.f03: New test.
 
 2018-01-23  Martin Liska  <mliska@suse.cz>
 
 2018-01-13  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/52162
-       * gfortran.dg/bounds_check_19.f90 : New test.
+       * gfortran.dg/bounds_check_19.f90: New test.
 
 2018-01-12  Jakub Jelinek  <jakub@redhat.com>
 
 2018-01-08  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/83611
-       * gfortran.dg/pdt_15.f03 : Bump count of 'n.data = 0B' to 8.
-       * gfortran.dg/pdt_26.f03 : Bump count of '_malloc' to 9.
-       * gfortran.dg/pdt_27.f03 : New test.
+       * gfortran.dg/pdt_15.f03: Bump count of 'n.data = 0B' to 8.
+       * gfortran.dg/pdt_26.f03: Bump count of '_malloc' to 9.
+       * gfortran.dg/pdt_27.f03: New test.
 
        PR fortran/83731
-       * gfortran.dg/pdt_28.f03 : New test.
+       * gfortran.dg/pdt_28.f03: New test.
 
 2018-01-08  Tom de Vries  <tom@codesourcery.com>
 
 2018-01-01  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/83076
-       * gfortran.dg/coarray_45.f90 : New test.
+       * gfortran.dg/coarray_45.f90: New test.
 
        PR fortran/83319
-       * gfortran.dg/coarray_46.f90 : New test.
+       * gfortran.dg/coarray_46.f90: New test.
 
 2018-01-01  Jakub Jelinek  <jakub@redhat.com>
 
diff --git a/gcc/testsuite/g++.dg/ubsan/pr83987.C b/gcc/testsuite/g++.dg/ubsan/pr83987.C
new file mode 100644 (file)
index 0000000..7ba7952
--- /dev/null
@@ -0,0 +1,15 @@
+// PR sanitizer/83987
+// { dg-do compile { target fopenmp } }
+// { dg-options "-fopenmp -fsanitize=vptr -O0" }
+
+struct A { int i; };
+struct B : virtual A { void foo (); };
+
+void
+B::foo ()
+{
+#pragma omp sections lastprivate (i)
+  {
+    i = 0;
+  }
+}