summaryrefslogtreecommitdiff
path: root/gcc/trans-mem.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-02 13:44:41 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2015-10-02 13:44:41 +0000
commit639b72bd55ce62724a81d373298205ee07d1a081 (patch)
treeb5daceaf605c188f868a257193358864e67d69f3 /gcc/trans-mem.c
parente98c90e16bc3c6036ac0962e5657d8882d4afa21 (diff)
downloadgcc-639b72bd55ce62724a81d373298205ee07d1a081.tar.gz
PR c/59218
* trans-mem.c (volatile_lvalue_p): Rename from volatile_var_p. (diagnose_tm_1_op): Also diagnose volatile accesses in transaction_safe function. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@228392 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/trans-mem.c')
-rw-r--r--gcc/trans-mem.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index 5b43d86f6da..488c20e4c64 100644
--- a/gcc/trans-mem.c
+++ b/gcc/trans-mem.c
@@ -594,32 +594,36 @@ struct diagnose_tm
gimple *stmt;
};
-/* Return true if T is a volatile variable of some kind. */
+/* Return true if T is a volatile lvalue of some kind. */
static bool
-volatile_var_p (tree t)
+volatile_lvalue_p (tree t)
{
- return (SSA_VAR_P (t)
+ return ((SSA_VAR_P (t) || REFERENCE_CLASS_P (t))
&& TREE_THIS_VOLATILE (TREE_TYPE (t)));
}
/* Tree callback function for diagnose_tm pass. */
static tree
-diagnose_tm_1_op (tree *tp, int *walk_subtrees ATTRIBUTE_UNUSED,
- void *data)
+diagnose_tm_1_op (tree *tp, int *walk_subtrees, void *data)
{
struct walk_stmt_info *wi = (struct walk_stmt_info *) data;
struct diagnose_tm *d = (struct diagnose_tm *) wi->info;
- if (volatile_var_p (*tp)
- && d->block_flags & DIAG_TM_SAFE
- && !d->saw_volatile)
+ if (TYPE_P (*tp))
+ *walk_subtrees = false;
+ else if (volatile_lvalue_p (*tp)
+ && !d->saw_volatile)
{
d->saw_volatile = 1;
- error_at (gimple_location (d->stmt),
- "invalid volatile use of %qD inside transaction",
- *tp);
+ if (d->block_flags & DIAG_TM_SAFE)
+ error_at (gimple_location (d->stmt),
+ "invalid use of volatile lvalue inside transaction");
+ else if (d->func_flags & DIAG_TM_SAFE)
+ error_at (gimple_location (d->stmt),
+ "invalid use of volatile lvalue inside %<transaction_safe%>"
+ "function");
}
return NULL_TREE;
@@ -4298,7 +4302,7 @@ ipa_tm_scan_irr_block (basic_block bb)
{
tree lhs = gimple_assign_lhs (stmt);
tree rhs = gimple_assign_rhs1 (stmt);
- if (volatile_var_p (lhs) || volatile_var_p (rhs))
+ if (volatile_lvalue_p (lhs) || volatile_lvalue_p (rhs))
return true;
}
break;
@@ -4306,7 +4310,7 @@ ipa_tm_scan_irr_block (basic_block bb)
case GIMPLE_CALL:
{
tree lhs = gimple_call_lhs (stmt);
- if (lhs && volatile_var_p (lhs))
+ if (lhs && volatile_lvalue_p (lhs))
return true;
if (is_tm_pure_call (stmt))