]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c++/92992 (Side-effects dropped when decltype(nullptr) typed expression is...
authorJakub Jelinek <jakub@redhat.com>
Wed, 22 Jan 2020 16:39:55 +0000 (17:39 +0100)
committerJakub Jelinek <jakub@redhat.com>
Wed, 22 Jan 2020 19:12:54 +0000 (20:12 +0100)
PR c++/92992
* call.c (convert_arg_to_ellipsis): For decltype(nullptr) arguments
that have side-effects use cp_build_compound_expr.

* g++.dg/cpp0x/nullptr45.C: New test.

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/nullptr45.C [new file with mode: 0644]

index 0e1557c936e21967f5a2accb56be62afcead130b..f0e314fd35489b2ed60121ad706db60e0068095f 100644 (file)
@@ -1,3 +1,12 @@
+2020-01-22  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2019-12-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/92992
+       * call.c (convert_arg_to_ellipsis): For decltype(nullptr) arguments
+       that have side-effects use cp_build_compound_expr.
+
 2020-01-21  Jason Merrill  <jason@redhat.com>
 
        PR c++/91476 - anon-namespace reference temp clash between TUs.
index 8e14e89d5d498367ebfafb1d00bb2167322c8fb8..787a7ed387bd3bfdffaa3974045b8e6f4839e37b 100644 (file)
@@ -7543,7 +7543,12 @@ convert_arg_to_ellipsis (tree arg, tsubst_flags_t complain)
       arg = convert_to_real_nofold (double_type_node, arg);
     }
   else if (NULLPTR_TYPE_P (arg_type))
-    arg = null_pointer_node;
+    {
+      if (TREE_SIDE_EFFECTS (arg))
+       arg = cp_build_compound_expr (arg, null_pointer_node, complain);
+      else
+       arg = null_pointer_node;
+    }
   else if (INTEGRAL_OR_ENUMERATION_TYPE_P (arg_type))
     {
       if (SCOPED_ENUM_P (arg_type))
index d76c0598245204df51df708ecd95c7aa22d7f0ab..2e507fdfe505bf07e381e2892aeb733b8321cf2e 100644 (file)
@@ -1,3 +1,11 @@
+2020-01-22  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2019-12-20  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/92992
+       * g++.dg/cpp0x/nullptr45.C: New test.
+
 2020-01-22  Joseph Myers  <joseph@codesourcery.com>
 
        Backport from mainline:
diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr45.C b/gcc/testsuite/g++.dg/cpp0x/nullptr45.C
new file mode 100644 (file)
index 0000000..3ff2268
--- /dev/null
@@ -0,0 +1,24 @@
+// PR c++/92992
+// { dg-do run { target c++11 } }
+
+int a;
+
+void
+bar (int, ...)
+{
+}
+
+decltype (nullptr)
+baz ()
+{
+  a++;
+  return nullptr;
+}
+
+int
+main ()
+{
+  bar (0, baz ());
+  if (a != 1)
+    __builtin_abort ();
+}