diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index e2cf1b4bff1..a9e40c29022 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2013-04-11 Jakub Jelinek + + PR c++/56895 + * call.c (null_ptr_cst_p): Call fold_non_dependent_expr_sfinae before + calling maybe_constant_value for C++98. + 2013-04-11 Jason Merrill PR c++/56901 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 4c59866323e..88bf1006c7b 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -555,7 +555,7 @@ null_ptr_cst_p (tree t) { /* Core issue 903 says only literal 0 is a null pointer constant. */ if (cxx_dialect < cxx0x) - t = maybe_constant_value (t); + t = maybe_constant_value (fold_non_dependent_expr_sfinae (t, tf_none)); STRIP_NOPS (t); if (integer_zerop (t) && !TREE_OVERFLOW (t)) return true; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 21b44e70b73..a3a517e177e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2013-04-11 Jakub Jelinek + + PR c++/56895 + * g++.dg/template/arrow4.C: New test. + 2013-04-11 Eric Botcazou * gnat.dg/array23.adb: New test. diff --git a/gcc/testsuite/g++.dg/template/arrow4.C b/gcc/testsuite/g++.dg/template/arrow4.C new file mode 100644 index 00000000000..89e78221958 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/arrow4.C @@ -0,0 +1,19 @@ +// PR c++/56895 +// { dg-do compile } + +void fn (int *); +void fn (int); +extern struct A { bool foo (); A bar (); } *a; + +template +void +baz () +{ + fn (a->bar().foo() ? 1 : 0); +} + +void +test () +{ + baz<0> (); +}