aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constexpr.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2019-03-08 08:43:58 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2019-03-08 08:43:58 +0100
commited3ea9f271aecfdea1650c87f835efa70a6f1bac (patch)
treea4f0892b801ff3c5b2db353e1db1b132b8aed8b3 /gcc/cp/constexpr.c
parent560a46a5914a3cc55ade0cb0fe3d8e36d85d01cd (diff)
downloadgcc-ed3ea9f271aecfdea1650c87f835efa70a6f1bac.zip
gcc-ed3ea9f271aecfdea1650c87f835efa70a6f1bac.tar.gz
gcc-ed3ea9f271aecfdea1650c87f835efa70a6f1bac.tar.bz2
re PR c++/89599 (C-style function-pointer-to-void* cast is handled inconsistently)
PR c++/89599 * constexpr.c (potential_constant_expression_1): Reject REINTERPRET_CAST_P NOP_EXPRs. * g++.dg/ubsan/vptr-4.C: Adjust expected diagnostics. * g++.dg/parse/array-size2.C: Likewise. * g++.dg/cpp0x/constexpr-89599.C: New test. From-SVN: r269482
Diffstat (limited to 'gcc/cp/constexpr.c')
-rw-r--r--gcc/cp/constexpr.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 1c3c725..783d1fc 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -5961,6 +5961,13 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,
return true;
case NOP_EXPR:
+ if (REINTERPRET_CAST_P (t))
+ {
+ if (flags & tf_error)
+ error_at (loc, "a reinterpret_cast is not a constant expression");
+ return false;
+ }
+ /* FALLTHRU */
case CONVERT_EXPR:
case VIEW_CONVERT_EXPR:
/* -- a reinterpret_cast. FIXME not implemented, and this rule