An attempt to fix c++/68449.  We ICEd because pointer returned from
ctx->values->get points to NULL, so checking DECL_P on that is no no.
Fixed along the lines Jakub suggested in the PR.

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

2016-01-08  Marek Polacek  <pola...@redhat.com>

        PR c++/68449
        * constexpr.c (cxx_eval_constant_expression): Handle NULL initializer.

        * g++.dg/pr68449.C: New.

diff --git gcc/cp/constexpr.c gcc/cp/constexpr.c
index bcf26a6..f59d010 100644
--- gcc/cp/constexpr.c
+++ gcc/cp/constexpr.c
@@ -3195,7 +3195,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, 
tree t,
       if (VAR_P (r))
        if (tree *p = ctx->values->get (r))
          r = *p;
-      if (DECL_P (r))
+      if (r == NULL_TREE || DECL_P (r))
        {
          if (!ctx->quiet)
            non_const_var_error (r);
diff --git gcc/testsuite/g++.dg/pr68449.C gcc/testsuite/g++.dg/pr68449.C
index e69de29..7d86fe9 100644
--- gcc/testsuite/g++.dg/pr68449.C
+++ gcc/testsuite/g++.dg/pr68449.C
@@ -0,0 +1,9 @@
+// PR c++/68449
+// { dg-do compile }
+// { dg-options "-Wsign-compare" }
+
+int
+foo (int a)
+{
+  return __extension__ ({ int b; b; }) < 0;
+}

        Marek

Reply via email to