From dc8d2d00c52e29a4d68576cecdcc161484123195 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sun, 13 Nov 2016 01:52:15 -0500 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/constexpr.c | 4 ++-- gcc/testsuite/g++.dg/cpp0x/constexpr-complex2.C | 5 +++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-complex2.C 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, ""); -- 2.30.2