Commit 62276744 by Jakub Jelinek Committed by Jakub Jelinek

re PR middle-end/64937 (compare debug failure with -fsanitize=address)

	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
parent 43a68a9d
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> 2015-02-06 Renlin Li <renlin.li@arm.com>
* tree-ssa-forwprop.c (execute): Keep location info while rewrite * tree-ssa-forwprop.c (execute): Keep location info while rewrite
......
...@@ -18062,7 +18062,7 @@ gen_type_die_for_member (tree type, tree member, dw_die_ref context_die) ...@@ -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 /* Forward declare these functions, because they are mutually recursive
with their set_block_* pairing functions. */ with their set_block_* pairing functions. */
static void set_decl_origin_self (tree); 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 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 given BLOCK node is NULL, set the BLOCK_ABSTRACT_ORIGIN for the node so
...@@ -18135,59 +18135,72 @@ set_decl_origin_self (tree decl) ...@@ -18135,59 +18135,72 @@ set_decl_origin_self (tree decl)
} }
} }
/* Given a pointer to some BLOCK node, and a boolean value to set the /* Given a pointer to some BLOCK node, set the BLOCK_ABSTRACT flag to 1
"abstract" flags to, set that value into the BLOCK_ABSTRACT flag for and if it wasn't 1 before, push it to abstract_vec vector.
the given block, and for all local decls and all local sub-blocks For all local decls and all local sub-blocks (recursively) do it
(recursively) which are contained therein. */ too. */
static void static void
set_block_abstract_flags (tree stmt, int setting) set_block_abstract_flags (tree stmt, vec<tree> &abstract_vec)
{ {
tree local_decl; tree local_decl;
tree subblock; tree subblock;
unsigned int i; 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); for (local_decl = BLOCK_VARS (stmt);
local_decl != NULL_TREE; local_decl != NULL_TREE;
local_decl = DECL_CHAIN (local_decl)) local_decl = DECL_CHAIN (local_decl))
if (! DECL_EXTERNAL (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++) for (i = 0; i < BLOCK_NUM_NONLOCALIZED_VARS (stmt); i++)
{ {
local_decl = BLOCK_NONLOCALIZED_VAR (stmt, i); local_decl = BLOCK_NONLOCALIZED_VAR (stmt, i);
if ((TREE_CODE (local_decl) == VAR_DECL && !TREE_STATIC (local_decl)) if ((TREE_CODE (local_decl) == VAR_DECL && !TREE_STATIC (local_decl))
|| TREE_CODE (local_decl) == PARM_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); for (subblock = BLOCK_SUBBLOCKS (stmt);
subblock != NULL_TREE; subblock != NULL_TREE;
subblock = BLOCK_CHAIN (subblock)) 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 /* Given a pointer to some ..._DECL node, set DECL_ABSTRACT_P flag on it
"abstract" flags to, set that value into the DECL_ABSTRACT_P flag for the to 1 and if it wasn't 1 before, push to abstract_vec vector.
given decl, and (in the case where the decl is a FUNCTION_DECL) also In the case where the decl is a FUNCTION_DECL also set the abstract
set the abstract flags for all of the parameters, local vars, local flags for all of the parameters, local vars, local
blocks and sub-blocks (recursively) to the same setting. */ blocks and sub-blocks (recursively). */
static void 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) if (TREE_CODE (decl) == FUNCTION_DECL)
{ {
tree arg; tree arg;
for (arg = DECL_ARGUMENTS (decl); arg; arg = DECL_CHAIN (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 if (DECL_INITIAL (decl) != NULL_TREE
&& DECL_INITIAL (decl) != error_mark_node) && 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) ...@@ -18200,7 +18213,6 @@ dwarf2out_abstract_function (tree decl)
dw_die_ref old_die; dw_die_ref old_die;
tree save_fn; tree save_fn;
tree context; tree context;
int was_abstract;
hash_table<decl_loc_hasher> *old_decl_loc_table; hash_table<decl_loc_hasher> *old_decl_loc_table;
hash_table<dw_loc_list_hasher> *old_cached_dw_loc_list_table; hash_table<dw_loc_list_hasher> *old_cached_dw_loc_list_table;
int old_call_site_count, old_tail_call_site_count; int old_call_site_count, old_tail_call_site_count;
...@@ -18242,11 +18254,16 @@ dwarf2out_abstract_function (tree decl) ...@@ -18242,11 +18254,16 @@ dwarf2out_abstract_function (tree decl)
save_fn = current_function_decl; save_fn = current_function_decl;
current_function_decl = decl; current_function_decl = decl;
was_abstract = DECL_ABSTRACT_P (decl); auto_vec<tree, 64> abstract_vec;
set_decl_abstract_flags (decl, 1); set_decl_abstract_flags (decl, abstract_vec);
dwarf2out_decl (decl); dwarf2out_decl (decl);
if (! was_abstract) unsigned int i;
set_decl_abstract_flags (decl, 0); 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; current_function_decl = save_fn;
decl_loc_table = old_decl_loc_table; decl_loc_table = old_decl_loc_table;
......
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> 2015-02-06 Paul Thomas <pault@gcc.gnu.org>
PR fortran/63205 PR fortran/63205
......
// 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));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment