flags_from_decl_or_type() only handles a TYPE or DECL. Make this
explicit instead.
I also added a check in the use in trans-mem.c, just in case. The
subsequent conditionals should take care of the TM case.
It would be nice if Marc Glisse could provide the testcase he mentioned
was failing. Either way, the attached patch doesn't hurt.
Tested on x86-64 Linux.
OK?
commit b5830c04f011d6885e3a09f50602b8f5f495a408
Author: Aldy Hernandez <al...@redhat.com>
Date: Mon Dec 9 08:10:44 2013 -0800
PR tree-optimization/59149
* calls.c (flags_from_decl_or_type): Fail on non decl or type.
* trans-mem.c (diagnose_tm_1): Do not call flags_from_decl_or_type
if no type or decl.
diff --git a/gcc/calls.c b/gcc/calls.c
index 3963bc2..2226e78 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -769,6 +769,8 @@ flags_from_decl_or_type (const_tree exp)
|| lookup_attribute ("transaction_pure", TYPE_ATTRIBUTES (exp))))
flags |= ECF_TM_PURE;
}
+ else
+ gcc_unreachable ();
if (TREE_THIS_VOLATILE (exp))
{
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index b2adc3d..1603d82 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -677,7 +677,8 @@ diagnose_tm_1 (gimple_stmt_iterator *gsi, bool
*handled_ops_p,
}
else if (direct_call_p)
{
- if (flags_from_decl_or_type (fn) & ECF_TM_BUILTIN)
+ if (IS_TYPE_OR_DECL_P (fn)
+ && flags_from_decl_or_type (fn) & ECF_TM_BUILTIN)
is_safe = true;
else if (replacement)
{