aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2016-03-23 19:45:26 +0100
committerJakub Jelinek <jakub@gcc.gnu.org>2016-03-23 19:45:26 +0100
commit61637db3f2f55a1b97e6f466be012a131bede75d (patch)
treed41106a9190c0d64c3e6fedaa69e2c6ef89d400e /gcc/cp
parent048336099ee3c4e29510f140f5505ce2ad79bf55 (diff)
downloadgcc-61637db3f2f55a1b97e6f466be012a131bede75d.zip
gcc-61637db3f2f55a1b97e6f466be012a131bede75d.tar.gz
gcc-61637db3f2f55a1b97e6f466be012a131bede75d.tar.bz2
re PR c++/70323 (missing error on integer overflow in constexpr function result converted to bool)
PR c++/70323 * constexpr.c (cxx_eval_constant_expression): Diagnose overflow on TREE_OVERFLOW constants. * g++.dg/cpp0x/constexpr-70323.C: New test. From-SVN: r234438
Diffstat (limited to 'gcc/cp')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/constexpr.c9
2 files changed, 11 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 8b3918b..b7a1f39 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,9 @@
2016-03-23 Jakub Jelinek <jakub@redhat.com>
+ PR c++/70323
+ * constexpr.c (cxx_eval_constant_expression): Diagnose overflow
+ on TREE_OVERFLOW constants.
+
PR c++/70376
* cp-gimplify.c (genericize_omp_for_stmt): Don't walk OMP_FOR_CLAUSES
for OMP_TASKLOOP here.
diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index d71e488..4baf114 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -3321,8 +3321,13 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
}
if (CONSTANT_CLASS_P (t))
{
- if (TREE_OVERFLOW (t) && (!flag_permissive || ctx->quiet))
- *overflow_p = true;
+ if (TREE_OVERFLOW (t))
+ {
+ if (!ctx->quiet)
+ permerror (input_location, "overflow in constant expression");
+ if (!flag_permissive || ctx->quiet)
+ *overflow_p = true;
+ }
return t;
}