* semantics.c (maybe_constant_value): Handle overflowed input.
authorJason Merrill <jason@redhat.com>
Fri, 10 Jun 2011 03:56:08 +0000 (23:56 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 10 Jun 2011 03:56:08 +0000 (23:56 -0400)
From-SVN: r174885

gcc/cp/ChangeLog
gcc/cp/semantics.c
libstdc++-v3/ChangeLog
libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc

index 377780ae3adb53474c4c672a973038ad6de34883..e134c27418968872cb62e2cb96d340ac697ed025 100644 (file)
@@ -1,5 +1,8 @@
 2011-06-09  Jason Merrill  <jason@redhat.com>
 
+       * semantics.c (maybe_constant_value): Handle overflowed input.
+       (non_const_var_error): Handle non-constant DECL_INITIAL.
+
        * pt.c (build_non_dependent_expr): Use fold_non_dependent_expr_sfinae.
 
        * parser.c (cp_parser_constant_expression): Just return the
index bf6486be644470193724793dcb3f5cfcf6d1e177..481318e963d66a75a0d7c4d92638377bb1ba14f7 100644 (file)
@@ -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
index c8d33b1658c2b8f0e69375e9dce60abd18b0fd2a..1ad5db4e31e89bd1cead5b39a558ee81c4ee7a62 100644 (file)
@@ -1,5 +1,7 @@
 2011-06-09  Jason Merrill  <jason@redhat.com>
 
+       * testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Adjust.
+
        * testsuite/lib/prune.exp (libstdc++-dg-prune): Prune notes.
        * testsuite/20_util/duration/cons/1_neg.cc: Remove dg-excess-errors.
        * testsuite/20_util/duration/requirements/typedefs_neg2.cc: Likewise.
index 83f5ce11f03ef34d56b25e8a24509e3d10bd18ee..8aa72f2e3f142e3864b19f3742a081aa9a7331c1 100644 (file)
@@ -51,4 +51,5 @@ test04()
 // { dg-error "required from here" "" { target *-*-* } 46 }
 // { dg-error "denominator cannot be zero" "" { target *-*-* } 268 }
 // { dg-error "out of range" "" { target *-*-* } 269 }
-// { dg-error "overflow in constant expression" "" { target *-*-* } 109 }
+// { dg-error "overflow in constant expression" "" { target *-*-* } 61 }
+// { dg-prune-output "not a member" }