aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/decl.c
diff options
context:
space:
mode:
authorMarek Polacek <polacek@redhat.com>2019-08-13 15:05:48 +0000
committerMarek Polacek <mpolacek@gcc.gnu.org>2019-08-13 15:05:48 +0000
commitcb0a83f3437be73075fba17db68abbf240d17a36 (patch)
tree0697b0b4e87b5dc7ddb5c05fad90bdad5eaeccad /gcc/cp/decl.c
parent82614ffbfdb57dcc490a752f0d398bbe2a774864 (diff)
downloadgcc-cb0a83f3437be73075fba17db68abbf240d17a36.zip
gcc-cb0a83f3437be73075fba17db68abbf240d17a36.tar.gz
gcc-cb0a83f3437be73075fba17db68abbf240d17a36.tar.bz2
PR c++/90473 - wrong code with nullptr in default argument.
* call.c (null_ptr_cst_p): Update quote from the standard. * decl.c (check_default_argument): Don't return nullptr when the arg has side-effects. * g++.dg/cpp0x/nullptr42.C: New test. From-SVN: r274382
Diffstat (limited to 'gcc/cp/decl.c')
-rw-r--r--gcc/cp/decl.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index b8806e4..d91f251 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -13177,7 +13177,9 @@ check_default_argument (tree decl, tree arg, tsubst_flags_t complain)
/* Avoid redundant -Wzero-as-null-pointer-constant warnings at
the call sites. */
if (TYPE_PTR_OR_PTRMEM_P (decl_type)
- && null_ptr_cst_p (arg))
+ && null_ptr_cst_p (arg)
+ /* Don't lose side-effects as in PR90473. */
+ && !TREE_SIDE_EFFECTS (arg))
return nullptr_node;
/* [dcl.fct.default]