From d69167ce95371c38f13fdc562b8d19a13332b4a6 Mon Sep 17 00:00:00 2001
From: rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 11 Aug 2004 04:00:04 +0000
Subject: [PATCH]         * stor-layout.c (round_up): Check for 0/1 before
 dividing.         (round_down): Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@85792 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog     |  3 +++
 gcc/stor-layout.c | 10 ++++++++++
 2 files changed, 13 insertions(+)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0c7b2e7f934c..a51da9b73107 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,8 @@
 2004-08-10  Richard Henderson  <rth@redhat.com>
 
+	* stor-layout.c (round_up): Check for 0/1 before dividing.
+	(round_down): Likewise.
+
 	* tree-tailcall.c (suitable_for_tail_opt_p): Also check DECL_EXTERNAL.
 
 2004-08-09  Mark Mitchell  <mark@codesourcery.com>
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 772177077f2b..3a0acd707259 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -277,6 +277,11 @@ round_up (tree value, int divisor)
 {
   tree t;
 
+  if (divisor == 0)
+    abort ();
+  if (divisor == 1)
+    return value;
+
   /* If divisor is a power of two, simplify this to bit manipulation.  */
   if (divisor == (divisor & -divisor))
     {
@@ -302,6 +307,11 @@ round_down (tree value, int divisor)
 {
   tree t;
 
+  if (divisor == 0)
+    abort ();
+  if (divisor == 1)
+    return value;
+
   /* If divisor is a power of two, simplify this to bit manipulation.  */
   if (divisor == (divisor & -divisor))
     {
-- 
GitLab