diff options
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r-- | gcc/cp/semantics.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 54dd7e1..3eb955e 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1597,7 +1597,11 @@ finish_unary_op_expr (code, expr) tree expr; { tree result = build_x_unary_op (code, expr); - if (code == NEGATE_EXPR && TREE_CODE (expr) == INTEGER_CST) + /* Inside a template, build_x_unary_op does not fold the + expression. So check whether the result is folded before + setting TREE_NEGATED_INT. */ + if (code == NEGATE_EXPR && TREE_CODE (expr) == INTEGER_CST + && TREE_CODE (result) == INTEGER_CST) TREE_NEGATED_INT (result) = 1; overflow_warning (result); return result; |