re PR middle-end/64937 (compare debug failure with -fsanitize=address)
authorJakub Jelinek <jakub@redhat.com>
Fri, 6 Feb 2015 18:26:59 +0000 (19:26 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 6 Feb 2015 18:26:59 +0000 (19:26 +0100)
PR middle-end/64937
* dwarf2out.c (set_block_abstract_flags, set_decl_abstract_flags):
Replace setting argument with abstract_vec, always set BLOCK_ABSTRACT
or DECL_ABSTRACT_P flags to 1 rather than to setting, and if it wasn't
1 before, push it to abstract_vec.
(dwarf2out_abstract_function): Adjust caller.  Don't call
set_decl_abstract_flags second time, instead clear BLOCK_ABSTRACT or
DECL_ABSTRACT_P flags for all abstract_vec elts.

* g++.dg/asan/pr64937.C: New test.

From-SVN: r220483

gcc/ChangeLog
gcc/dwarf2out.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/asan/pr64937.C [new file with mode: 0644]

index 47d98ad..59ed4b2 100644 (file)
@@ -1,3 +1,14 @@
+2015-02-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/64937
+       * dwarf2out.c (set_block_abstract_flags, set_decl_abstract_flags):
+       Replace setting argument with abstract_vec, always set BLOCK_ABSTRACT
+       or DECL_ABSTRACT_P flags to 1 rather than to setting, and if it wasn't
+       1 before, push it to abstract_vec.
+       (dwarf2out_abstract_function): Adjust caller.  Don't call
+       set_decl_abstract_flags second time, instead clear BLOCK_ABSTRACT or
+       DECL_ABSTRACT_P flags for all abstract_vec elts.
+
 2015-02-06  Renlin Li  <renlin.li@arm.com>
 
        * tree-ssa-forwprop.c (execute): Keep location info while rewrite
index db82710..8c3f1c0 100644 (file)
@@ -18062,7 +18062,7 @@ gen_type_die_for_member (tree type, tree member, dw_die_ref context_die)
 /* Forward declare these functions, because they are mutually recursive
   with their set_block_* pairing functions.  */
 static void set_decl_origin_self (tree);
-static void set_decl_abstract_flags (tree, int);
+static void set_decl_abstract_flags (tree, vec<tree> &);
 
 /* Given a pointer to some BLOCK node, if the BLOCK_ABSTRACT_ORIGIN for the
    given BLOCK node is NULL, set the BLOCK_ABSTRACT_ORIGIN for the node so
@@ -18135,59 +18135,72 @@ set_decl_origin_self (tree decl)
     }
 }
 \f
-/* Given a pointer to some BLOCK node, and a boolean value to set the
-   "abstract" flags to, set that value into the BLOCK_ABSTRACT flag for
-   the given block, and for all local decls and all local sub-blocks
-   (recursively) which are contained therein.  */
+/* Given a pointer to some BLOCK node, set the BLOCK_ABSTRACT flag to 1
+   and if it wasn't 1 before, push it to abstract_vec vector.
+   For all local decls and all local sub-blocks (recursively) do it
+   too.  */
 
 static void
-set_block_abstract_flags (tree stmt, int setting)
+set_block_abstract_flags (tree stmt, vec<tree> &abstract_vec)
 {
   tree local_decl;
   tree subblock;
   unsigned int i;
 
-  BLOCK_ABSTRACT (stmt) = setting;
+  if (!BLOCK_ABSTRACT (stmt))
+    {
+      abstract_vec.safe_push (stmt);
+      BLOCK_ABSTRACT (stmt) = 1;
+    }
 
   for (local_decl = BLOCK_VARS (stmt);
        local_decl != NULL_TREE;
        local_decl = DECL_CHAIN (local_decl))
     if (! DECL_EXTERNAL (local_decl))
-      set_decl_abstract_flags (local_decl, setting);
+      set_decl_abstract_flags (local_decl, abstract_vec);
 
   for (i = 0; i < BLOCK_NUM_NONLOCALIZED_VARS (stmt); i++)
     {
       local_decl = BLOCK_NONLOCALIZED_VAR (stmt, i);
       if ((TREE_CODE (local_decl) == VAR_DECL && !TREE_STATIC (local_decl))
          || TREE_CODE (local_decl) == PARM_DECL)
-       set_decl_abstract_flags (local_decl, setting);
+       set_decl_abstract_flags (local_decl, abstract_vec);
     }
 
   for (subblock = BLOCK_SUBBLOCKS (stmt);
        subblock != NULL_TREE;
        subblock = BLOCK_CHAIN (subblock))
-    set_block_abstract_flags (subblock, setting);
+    set_block_abstract_flags (subblock, abstract_vec);
 }
 
-/* Given a pointer to some ..._DECL node, and a boolean value to set the
-   "abstract" flags to, set that value into the DECL_ABSTRACT_P flag for the
-   given decl, and (in the case where the decl is a FUNCTION_DECL) also
-   set the abstract flags for all of the parameters, local vars, local
-   blocks and sub-blocks (recursively) to the same setting.  */
+/* Given a pointer to some ..._DECL node, set DECL_ABSTRACT_P flag on it
+   to 1 and if it wasn't 1 before, push to abstract_vec vector.
+   In the case where the decl is a FUNCTION_DECL also set the abstract
+   flags for all of the parameters, local vars, local
+   blocks and sub-blocks (recursively).  */
 
 static void
-set_decl_abstract_flags (tree decl, int setting)
+set_decl_abstract_flags (tree decl, vec<tree> &abstract_vec)
 {
-  DECL_ABSTRACT_P (decl) = setting;
+  if (!DECL_ABSTRACT_P (decl))
+    {
+      abstract_vec.safe_push (decl);
+      DECL_ABSTRACT_P (decl) = 1;
+    }
+
   if (TREE_CODE (decl) == FUNCTION_DECL)
     {
       tree arg;
 
       for (arg = DECL_ARGUMENTS (decl); arg; arg = DECL_CHAIN (arg))
-       DECL_ABSTRACT_P (arg) = setting;
+       if (!DECL_ABSTRACT_P (arg))
+         {
+           abstract_vec.safe_push (arg);
+           DECL_ABSTRACT_P (arg) = 1;
+         }
       if (DECL_INITIAL (decl) != NULL_TREE
          && DECL_INITIAL (decl) != error_mark_node)
-       set_block_abstract_flags (DECL_INITIAL (decl), setting);
+       set_block_abstract_flags (DECL_INITIAL (decl), abstract_vec);
     }
 }
 
@@ -18200,7 +18213,6 @@ dwarf2out_abstract_function (tree decl)
   dw_die_ref old_die;
   tree save_fn;
   tree context;
-  int was_abstract;
   hash_table<decl_loc_hasher> *old_decl_loc_table;
   hash_table<dw_loc_list_hasher> *old_cached_dw_loc_list_table;
   int old_call_site_count, old_tail_call_site_count;
@@ -18242,11 +18254,16 @@ dwarf2out_abstract_function (tree decl)
   save_fn = current_function_decl;
   current_function_decl = decl;
 
-  was_abstract = DECL_ABSTRACT_P (decl);
-  set_decl_abstract_flags (decl, 1);
+  auto_vec<tree, 64> abstract_vec;
+  set_decl_abstract_flags (decl, abstract_vec);
   dwarf2out_decl (decl);
-  if (! was_abstract)
-    set_decl_abstract_flags (decl, 0);
+  unsigned int i;
+  tree t;
+  FOR_EACH_VEC_ELT (abstract_vec, i, t)
+    if (TREE_CODE (t) == BLOCK)
+      BLOCK_ABSTRACT (t) = 0;
+    else
+      DECL_ABSTRACT_P (t) = 0;
 
   current_function_decl = save_fn;
   decl_loc_table = old_decl_loc_table;
index 921478e..d17c672 100644 (file)
@@ -1,3 +1,8 @@
+2015-02-06  Jakub Jelinek  <jakub@redhat.com>
+
+       PR middle-end/64937
+       * g++.dg/asan/pr64937.C: New test.
+
 2015-02-06  Paul Thomas  <pault@gcc.gnu.org>
 
        PR fortran/63205
diff --git a/gcc/testsuite/g++.dg/asan/pr64937.C b/gcc/testsuite/g++.dg/asan/pr64937.C
new file mode 100644 (file)
index 0000000..91beee0
--- /dev/null
@@ -0,0 +1,30 @@
+// PR middle-end/64937
+// { dg-do compile }
+// { dg-options "-fsanitize=address -fcompare-debug" }
+
+namespace foo_aux {
+  struct BarParser { };
+}
+extern "C" {
+  extern void __assert_fail (__const char *__assertion, __const char *__file,
+                             unsigned int __line, __const char *__function);
+}
+namespace foo {
+  class BarBox {
+  public:
+    BarBox (int xl = 0, int yl = 0) { }
+  };
+  class BarFoo {
+  public:
+    explicit BarFoo (BarBox box) {
+      ((_orig_mask) ? static_cast < void >(0) :
+       __assert_fail ("_orig_mask", "foo.h", 159, __PRETTY_FUNCTION__));
+    }
+    BarBox *_orig_mask;
+  };
+}
+static void
+ProcessOp (foo_aux::BarParser * p, int xl, int yr)
+{
+  foo::BarFoo tiles (foo::BarBox (xl, yr));
+}