From: Jason Merrill Date: Sun, 13 Nov 2016 06:52:15 +0000 (-0500) Subject: Fix constexpr lvalue use of __real and __imag. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=dc8d2d00c52e29a4d68576cecdcc161484123195;p=gcc.git Fix constexpr lvalue use of __real and __imag. * constexpr.c (potential_constant_expression_1): REALPART_EXPR and IMAGPART_EXPR can be lvalues. From-SVN: r242349 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 60186ee9fb8..b2195e4b687 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2016-11-12 Jason Merrill + * constexpr.c (potential_constant_expression_1): REALPART_EXPR and + IMAGPART_EXPR can be lvalues. + DR 374 PR c++/56840 * pt.c (check_specialization_namespace): Allow any enclosing diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index f75f0b039fa..739e902cf6a 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -5105,6 +5105,8 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, #endif return RECUR (t, any); + case REALPART_EXPR: + case IMAGPART_EXPR: case COMPONENT_REF: case BIT_FIELD_REF: case ARROW_EXPR: @@ -5276,8 +5278,6 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, return true; /* fall through. */ - case REALPART_EXPR: - case IMAGPART_EXPR: case CONJ_EXPR: case SAVE_EXPR: case FIX_TRUNC_EXPR: diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-complex2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-complex2.C new file mode 100644 index 00000000000..9a9291b264c --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-complex2.C @@ -0,0 +1,5 @@ +// { dg-do compile { target c++11 } } +// { dg-options "" } + +static _Complex int i; +static_assert (&__imag i == &__imag i, "");