re PR c++/71828 (ICE on valid C++11 code with constexpr __Complex int variable declar...
authorJakub Jelinek <jakub@redhat.com>
Mon, 18 Jul 2016 18:43:19 +0000 (20:43 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 18 Jul 2016 18:43:19 +0000 (20:43 +0200)
PR c++/71828
* constexpr.c (cxx_eval_constant_expression) <case REALPART_EXPR>:
For lval don't use cxx_eval_unary_expression and instead recurse
and if needed rebuild the reference.

* g++.dg/cpp0x/constexpr-71828.C: New test.

From-SVN: r238442

gcc/cp/ChangeLog
gcc/cp/constexpr.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-71828.C [new file with mode: 0644]

index 899b2aeb656797f60fb35d0a405fd61820e73b77..87d666e4930b486e3c3cfaca823013b853ff4b92 100644 (file)
@@ -1,5 +1,10 @@
 2016-07-18  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/71828
+       * constexpr.c (cxx_eval_constant_expression) <case REALPART_EXPR>:
+       For lval don't use cxx_eval_unary_expression and instead recurse
+       and if needed rebuild the reference.
+
        PR c++/71826
        * pt.c (tsubst_baselink): Only set BASELINK_OPTYPE for BASELINK_P.
 
index cb8ece0773feb277a352bfd739a959bba7a55a79..91d14a55b4ff0c6b7c7789d167a3d08e9c5490dc 100644 (file)
@@ -3800,6 +3800,19 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
 
     case REALPART_EXPR:
     case IMAGPART_EXPR:
+      if (lval)
+       {
+         r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0), lval,
+                                           non_constant_p, overflow_p);
+         if (r == error_mark_node)
+           ;
+         else if (r == TREE_OPERAND (t, 0))
+           r = t;
+         else
+           r = fold_build1 (TREE_CODE (t), TREE_TYPE (t), r);
+         break;
+       }
+      /* FALLTHRU */
     case CONJ_EXPR:
     case FIX_TRUNC_EXPR:
     case FLOAT_EXPR:
index 060fcebbf017a09c0df46ed639006a11617602bd..ff3e335735359a57da09ea73d4bb1e8aaba5c35a 100644 (file)
@@ -1,5 +1,8 @@
 2016-07-18  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/71828
+       * g++.dg/cpp0x/constexpr-71828.C: New test.
+
        PR c++/71826
        * g++.dg/template/pr71826.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-71828.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-71828.C
new file mode 100644 (file)
index 0000000..b74cde9
--- /dev/null
@@ -0,0 +1,5 @@
+// PR c++/71828
+// { dg-do compile { target c++11 } }
+
+constexpr _Complex int a { 1, 2 };
+static_assert (& __imag a != &__real a, "");