]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/84686 - missing volatile loads.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 4 Mar 2018 05:32:39 +0000 (05:32 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 4 Mar 2018 05:32:39 +0000 (05:32 +0000)
* cvt.c (convert_to_void): Call maybe_undo_parenthesized_ref.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258231 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/cvt.c
gcc/testsuite/g++.dg/tree-ssa/volatile2.C [new file with mode: 0644]

index 391aa5f11fe831564a4c100c3b1600a798e7591d..942b7e89aaee086851f20836b30b5cda1f3b763c 100644 (file)
@@ -1,3 +1,8 @@
+2018-03-03  Jason Merrill  <jason@redhat.com>
+
+       PR c++/84686 - missing volatile loads.
+       * cvt.c (convert_to_void): Call maybe_undo_parenthesized_ref.
+
 2018-03-03  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/71464
index f5da08bbee2435cfa80a838b71e60c743be958d3..40e7576f23c8a2434cab403c29329a276149ac03 100644 (file)
@@ -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 (file)
index 0000000..bec6044
--- /dev/null
@@ -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
+}