]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
PR c++/84686 - missing volatile loads.
authorJason Merrill <jason@redhat.com>
Mon, 5 Mar 2018 14:28:15 +0000 (09:28 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 5 Mar 2018 14:28:15 +0000 (09:28 -0500)
* cvt.c (convert_to_void): Call maybe_undo_parenthesized_ref.

From-SVN: r258246

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

index ab5a911f44ffb4477b3c6409494bf42436ae5810..763a6947ec25605dff8852625b447eecc5dbfed4 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-02  Jason Merrill  <jason@redhat.com>
 
        PR c++/84489 - dependent default template argument
index 0d1048cd7fe4259cfc4f7a29420ae8f98f833c1c..43fcff9854eaeda2aa894ed5b5646309bf8ece6b 100644 (file)
@@ -932,6 +932,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);
+
   if (implicit == ICV_CAST)
     mark_exp_read (expr);
   else
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
+}