From: Jason Merrill Date: Sun, 4 Mar 2018 05:32:39 +0000 (-0500) Subject: PR c++/84686 - missing volatile loads. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=38946ea192bf484cc854dd407d34cce4de6b698b;p=gcc.git PR c++/84686 - missing volatile loads. * cvt.c (convert_to_void): Call maybe_undo_parenthesized_ref. From-SVN: r258231 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 391aa5f11fe..942b7e89aae 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,8 @@ +2018-03-03 Jason Merrill + + PR c++/84686 - missing volatile loads. + * cvt.c (convert_to_void): Call maybe_undo_parenthesized_ref. + 2018-03-03 Paolo Carlini PR c++/71464 diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index f5da08bbee2..40e7576f23c 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -1063,6 +1063,8 @@ convert_to_void (tree expr, impl_conv_void implicit, tsubst_flags_t complain) || TREE_TYPE (expr) == error_mark_node) return error_mark_node; + expr = maybe_undo_parenthesized_ref (expr); + expr = mark_discarded_use (expr); if (implicit == ICV_CAST) /* An explicit cast to void avoids all -Wunused-but-set* warnings. */ diff --git a/gcc/testsuite/g++.dg/tree-ssa/volatile2.C b/gcc/testsuite/g++.dg/tree-ssa/volatile2.C new file mode 100644 index 00000000000..bec60442477 --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/volatile2.C @@ -0,0 +1,20 @@ +// PR c++/84686 +// { dg-additional-options -fdump-tree-gimple } +// { dg-final { scan-tree-dump-times "= i" 10 "gimple" } } + +volatile int i; + +int main() +{ + i; //evaluated (a load is performed) + (i); //unevaluated => the load shall be performed + + (void)i; //evaluated (a load is performed) + (void)(i); //unevaluated => the load shall be performed + + (void)i; //evaluated (a load is performed) + (void)(i); //unevaluated => the load shall be performed + + (i,i); // the two subexpression are evaluated + ((i),(i)); // no evaluation, => two loads shall happen +}