[committed] Backports to 9.x branch
diff mbox series

Message ID 20200122193108.GP10088@tucnak
State New
Headers show
Series
  • [committed] Backports to 9.x branch
Related show

Commit Message

Jakub Jelinek Jan. 22, 2020, 7:31 p.m. UTC
Hi!

I've backported these 15 commits from trunk to 9.x branch,
bootstrapped/regtested them on x86_64-linux and i686-linux and
committed.

	Jakub
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                       |  9 +++++++++
 gcc/cp/call.c                          |  7 ++++++-
 gcc/testsuite/ChangeLog                |  8 ++++++++
 gcc/testsuite/g++.dg/cpp0x/nullptr45.C | 24 ++++++++++++++++++++++++
 4 files changed, 47 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/nullptr45.C

Patch
diff mbox series

diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 0e1557c936e..f0e314fd354 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 8e14e89d5d4..787a7ed387b 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -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))
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d76c0598245..2e507fdfe50 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 00000000000..3ff226803df
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/nullptr45.C
@@ -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 ();
+}