OSDN Git Service

PR c++/56895
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 11 Apr 2013 19:42:33 +0000 (19:42 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 11 Apr 2013 19:42:33 +0000 (19:42 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@197824 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/template/arrow4.C [new file with mode: 0644]

index e2cf1b4..a9e40c2 100644 (file)
@@ -1,3 +1,9 @@
+2013-04-11  Jakub Jelinek  <jakub@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.
+
 2013-04-11  Jason Merrill  <jason@redhat.com>
 
        PR c++/56901
index 4c59866..88bf100 100644 (file)
@@ -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;
index 21b44e7..a3a517e 100644 (file)
@@ -1,3 +1,8 @@
+2013-04-11  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/56895
+       * g++.dg/template/arrow4.C: New test.
+
 2013-04-11  Eric Botcazou  <ebotcazou@adacore.com>
 
        * 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 (file)
index 0000000..89e7822
--- /dev/null
@@ -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> ();
+}