aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/semantics.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-06-09 23:56:08 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-06-09 23:56:08 -0400
commit793fbf0b4857056c5723a5e2b9fc20c3726726c5 (patch)
treecec6f934c5272457884f62365f6a20071d4ea789 /gcc/cp/semantics.c
parent377a5364302b126840da543d6acf46b68e59a486 (diff)
downloadgcc-793fbf0b4857056c5723a5e2b9fc20c3726726c5.zip
gcc-793fbf0b4857056c5723a5e2b9fc20c3726726c5.tar.gz
gcc-793fbf0b4857056c5723a5e2b9fc20c3726726c5.tar.bz2
* semantics.c (maybe_constant_value): Handle overflowed input.
From-SVN: r174885
Diffstat (limited to 'gcc/cp/semantics.c')
-rw-r--r--gcc/cp/semantics.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index bf6486b..481318e 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -6902,7 +6902,8 @@ non_const_var_error (tree r)
else if (CP_TYPE_VOLATILE_P (type))
inform (DECL_SOURCE_LOCATION (r),
"%q#D is volatile", r);
- else if (!DECL_INITIAL (r))
+ else if (!DECL_INITIAL (r)
+ || !TREE_CONSTANT (DECL_INITIAL (r)))
inform (DECL_SOURCE_LOCATION (r),
"%qD was not initialized with a constant "
"expression", r);
@@ -7337,7 +7338,14 @@ maybe_constant_value (tree t)
|| type_unknown_p (t)
|| !potential_constant_expression (t)
|| value_dependent_expression_p (t))
- return t;
+ {
+ if (TREE_OVERFLOW_P (t))
+ {
+ t = build_nop (TREE_TYPE (t), t);
+ TREE_CONSTANT (t) = false;
+ }
+ return t;
+ }
r = cxx_eval_outermost_constant_expr (t, true);
#ifdef ENABLE_CHECKING