diff options
author | Jason Merrill <jason@redhat.com> | 2013-02-25 23:27:40 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2013-02-25 23:27:40 -0500 |
commit | 70e9ab23f4ad839bd0979da933101a0da8fbefe9 (patch) | |
tree | 2f05abfe639fd33aacc6d14d4b41b41b3cdde14d /gcc/cp/semantics.c | |
parent | d2b512dc5d40e59d5c083eaa73dda750a373fe03 (diff) | |
download | gcc-70e9ab23f4ad839bd0979da933101a0da8fbefe9.zip gcc-70e9ab23f4ad839bd0979da933101a0da8fbefe9.tar.gz gcc-70e9ab23f4ad839bd0979da933101a0da8fbefe9.tar.bz2 |
re PR c++/56438 (ICE in value_dependent_expression_p, at cp/pt.c:19551)
PR c++/56438
* semantics.c (potential_constant_expression_1): In C++98, a cast
to non-integral type can't be a constant expression.
From-SVN: r196274
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r-- | gcc/cp/semantics.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 458ed26..60271b5 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -8607,6 +8607,18 @@ potential_constant_expression_1 (tree t, bool want_rval, tsubst_flags_t flags) case STATIC_CAST_EXPR: case REINTERPRET_CAST_EXPR: case IMPLICIT_CONV_EXPR: + if (cxx_dialect < cxx0x + && !dependent_type_p (TREE_TYPE (t)) + && !INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (t))) + /* In C++98, a conversion to non-integral type can't be part of a + constant expression. */ + { + if (flags & tf_error) + error ("cast to non-integral type %qT in a constant expression", + TREE_TYPE (t)); + return false; + } + return (potential_constant_expression_1 (TREE_OPERAND (t, 0), TREE_CODE (TREE_TYPE (t)) != REFERENCE_TYPE, flags)); |