summaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-18 14:55:23 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2015-06-18 14:55:23 +0000
commit7f67d68c56e531d17a1d9150fac23671c052c02e (patch)
tree06a7f084677619ac8ab0087fe06bf716fe115ce9 /gcc/cp
parentc01ee3258d0a8a4aa66f32834c5d339cf03e5790 (diff)
downloadgcc-7f67d68c56e531d17a1d9150fac23671c052c02e.tar.gz
PR c++/66001
* constexpr.c (cxx_eval_constant_expression): Handle TRY_BLOCK and TRY_FINALLY_EXPR. (potential_constant_expression_1): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224620 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/constexpr.c17
2 files changed, 24 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 153b3c4cd74..eb8d97ab1e8 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,12 @@
2015-06-17 Jason Merrill <jason@redhat.com>
+ PR c++/66001
+ * constexpr.c (cxx_eval_constant_expression): Handle TRY_BLOCK and
+ TRY_FINALLY_EXPR.
+ (potential_constant_expression_1): Likewise.
+
+2015-06-17 Jason Merrill <jason@redhat.com>
+
PR c++/66515
* call.c (implicit_conversion): Call reshape_init here, early.
(build_aggr_conv): Not here.
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index a52c96ff6b4..56885883d72 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -3182,6 +3182,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
case NON_LVALUE_EXPR:
case TRY_CATCH_EXPR:
+ case TRY_BLOCK:
case CLEANUP_POINT_EXPR:
case MUST_NOT_THROW_EXPR:
case EXPR_STMT:
@@ -3192,6 +3193,17 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
jump_target);
break;
+ case TRY_FINALLY_EXPR:
+ r = cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 0), lval,
+ non_constant_p, overflow_p,
+ jump_target);
+ if (!*non_constant_p)
+ /* Also evaluate the cleanup. */
+ cxx_eval_constant_expression (ctx, TREE_OPERAND (t, 1), true,
+ non_constant_p, overflow_p,
+ jump_target);
+ break;
+
/* These differ from cxx_eval_unary_expression in that this doesn't
check for a constant operand or result; an address can be
constant without its operand being, and vice versa. */
@@ -4266,6 +4278,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict,
case CLEANUP_POINT_EXPR:
case MUST_NOT_THROW_EXPR:
case TRY_CATCH_EXPR:
+ case TRY_BLOCK:
case EH_SPEC_BLOCK:
case EXPR_STMT:
case PAREN_EXPR:
@@ -4275,6 +4288,10 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict,
case RETURN_EXPR:
return RECUR (TREE_OPERAND (t, 0), want_rval);
+ case TRY_FINALLY_EXPR:
+ return (RECUR (TREE_OPERAND (t, 0), want_rval)
+ && RECUR (TREE_OPERAND (t, 1), any));
+
case SCOPE_REF:
return RECUR (TREE_OPERAND (t, 1), want_rval);