Hi!

Hopefully last problematic spot, other places where maybe_constant_value
calls have been introduced are either guarded with
!processing_template_decl, or I haven't succeeded in triggering ICEs (say in
build_new_1).

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2013-04-11  Jakub Jelinek  <ja...@redhat.com>

        PR c++/56895
        * call.c (null_ptr_cst_p): Call fold_non_dependent_expr_sfinae before
        calling maybe_constant_value for C++98.

        * g++.dg/template/arrow4.C: New test.

--- gcc/cp/call.c.jj    2013-04-02 20:24:34.000000000 +0200
+++ gcc/cp/call.c       2013-04-11 09:55:05.408797608 +0200
@@ -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;
--- gcc/testsuite/g++.dg/template/arrow4.C.jj   2013-04-11 09:54:10.803117048 
+0200
+++ gcc/testsuite/g++.dg/template/arrow4.C      2013-04-11 09:56:28.007313310 
+0200
@@ -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 <int>
+void
+baz ()
+{
+  fn (a->bar().foo() ? 1 : 0);
+}
+
+void
+test ()
+{
+  baz<0> ();
+}

        Jakub

Reply via email to