re PR c++/84463 (Supposedly-incompliant "error: '* key0' is not a constant expression")
authorJakub Jelinek <jakub@redhat.com>
Wed, 18 Apr 2018 06:57:45 +0000 (08:57 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 18 Apr 2018 06:57:45 +0000 (08:57 +0200)
commit715dd933bd56edc7498495dc7dfe66768347f7b5
treef9814ccf3cf6d6f69a67656064fc3303ac49c7d6
parenta56e2f69fede451499cfcbb58bab7687e4b1643a
re PR c++/84463 (Supposedly-incompliant "error: '* key0' is not a constant expression")

PR c++/84463
* typeck.c (cp_build_addr_expr_1): Move handling of offsetof-like
tricks from here to ...
* cp-gimplify.c (cp_fold) <case ADDR_EXPR>: ... here.  Only use it
if INDIRECT_REF's operand is INTEGER_CST cast to pointer type.

* g++.dg/cpp0x/constexpr-nullptr-1.C: Add -O1 to dg-options.
* g++.dg/cpp0x/constexpr-nullptr-2.C: Expect different diagnostics
in two cases.  Uncomment two other tests and add expected dg-error for
them.
* g++.dg/init/struct2.C: Cast to int rather than long to avoid
-Wnarrowing diagnostics on some targets for c++11.
* g++.dg/parse/array-size2.C: Remove xfail.
* g++.dg/cpp0x/constexpr-84463.C: New test.

From-SVN: r259458
gcc/cp/ChangeLog
gcc/cp/cp-gimplify.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/constexpr-84463.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/constexpr-nullptr-1.C
gcc/testsuite/g++.dg/cpp0x/constexpr-nullptr-2.C
gcc/testsuite/g++.dg/init/struct2.C
gcc/testsuite/g++.dg/parse/array-size2.C