diff options
author | Jason Merrill <jason@redhat.com> | 2018-02-16 16:03:02 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2018-02-16 16:03:02 -0500 |
commit | 18afe4c9fcfef7d03832816581fb8804cde0aa4e (patch) | |
tree | 1da777f19f6dda74450c197d022f78fe8e819c05 /gcc/cp/call.c | |
parent | 3664e317b8efce5e4b37aca4724b05945bcbbb4f (diff) | |
download | gcc-18afe4c9fcfef7d03832816581fb8804cde0aa4e.zip gcc-18afe4c9fcfef7d03832816581fb8804cde0aa4e.tar.gz gcc-18afe4c9fcfef7d03832816581fb8804cde0aa4e.tar.bz2 |
PR c++/84151 - unnecessary volatile load with static member.
* call.c (build_new_method_call_1): Avoid loading from a volatile
lvalue used as the object argument for a static member function.
From-SVN: r257763
Diffstat (limited to 'gcc/cp/call.c')
-rw-r--r-- | gcc/cp/call.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gcc/cp/call.c b/gcc/cp/call.c index d3d0966..7c93c6d 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -9284,8 +9284,14 @@ build_new_method_call_1 (tree instance, tree fns, vec<tree, va_gc> **args, if (TREE_CODE (TREE_TYPE (fn)) != METHOD_TYPE && !is_dummy_object (instance) && TREE_SIDE_EFFECTS (instance)) - call = build2 (COMPOUND_EXPR, TREE_TYPE (call), - instance, call); + { + /* But avoid the implicit lvalue-rvalue conversion when 'a' + is volatile. */ + tree a = instance; + if (TREE_THIS_VOLATILE (a)) + a = build_this (a); + call = build2 (COMPOUND_EXPR, TREE_TYPE (call), a, call); + } else if (call != error_mark_node && DECL_DESTRUCTOR_P (cand->fn) && !VOID_TYPE_P (TREE_TYPE (call))) |