diff options
author | Jakub Jelinek <jakub@redhat.com> | 2019-12-21 00:15:52 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2019-12-21 00:15:52 +0100 |
commit | 6c7b84305a5e686644ee64bfd2d415f3f43fa85b (patch) | |
tree | cc382e715df3c3c3010ee31a808f3130b7fe8ed3 /gcc | |
parent | 03e487e541c0a43736507654b60267bbe19a5ead (diff) | |
download | gcc-6c7b84305a5e686644ee64bfd2d415f3f43fa85b.zip gcc-6c7b84305a5e686644ee64bfd2d415f3f43fa85b.tar.gz gcc-6c7b84305a5e686644ee64bfd2d415f3f43fa85b.tar.bz2 |
re PR c++/92992 (Side-effects dropped when decltype(nullptr) typed expression is passed to ellipsis)
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.
From-SVN: r279680
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/cp/call.c | 7 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/nullptr45.C | 24 |
4 files changed, 41 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 37353e9..c6858f9 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +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. + 2019-12-20 Eric Botcazou <ebotcazou@adacore.com> * decl2.c (c_parse_final_cleanups): Always call collect_source_ref on diff --git a/gcc/cp/call.c b/gcc/cp/call.c index cbd5747..aeddf30 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -7822,7 +7822,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 8a235b5..d2e1464 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-12-20 Jakub Jelinek <jakub@redhat.com> + + PR c++/92992 + * g++.dg/cpp0x/nullptr45.C: New test. + 2019-12-20 Jonathan Wakely <jwakely@redhat.com> PR fortran/69497 diff --git a/gcc/testsuite/g++.dg/cpp0x/nullptr45.C b/gcc/testsuite/g++.dg/cpp0x/nullptr45.C new file mode 100644 index 0000000..3ff2268 --- /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 (); +} |