From 26dff611b5efbcf23b81f035cc1cd7f0946ca4ad Mon Sep 17 00:00:00 2001
From: rearnsha <rearnsha@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 31 May 2006 13:39:48 +0000
Subject: [PATCH] 	* arm.c (arm_print_operand case 'S'): Validate that
 the operand is 	a shift operand before calling shift_op.  Avoid
 redundant call of 	shift_op.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@114264 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog        |  6 ++++++
 gcc/config/arm/arm.c | 12 ++++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 04a83735875f..170bfa54b048 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2006-05-31  Richard Earnshaw  <richard.earnshaw@arm.com>
+
+	* arm.c (arm_print_operand case 'S'): Validate that the operand is
+	a shift operand before calling shift_op.  Avoid redundant call of
+	shift_op.
+
 2006-05-30  Naveen.H.S  <naveenh@kpitcummins.com>
 	    DJ Delorie  <dj@redhat.com>
 
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index a26222a932b5..a36c0d791760 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -11013,11 +11013,19 @@ arm_print_operand (FILE *stream, rtx x, int code)
     case 'S':
       {
 	HOST_WIDE_INT val;
-	const char * shift = shift_op (x, &val);
+	const char *shift;
+
+	if (!shift_operator (x, SImode))
+	  {
+	    output_operand_lossage ("invalid shift operand");
+	    break;
+	  }
+
+	shift = shift_op (x, &val);
 
 	if (shift)
 	  {
-	    fprintf (stream, ", %s ", shift_op (x, &val));
+	    fprintf (stream, ", %s ", shift);
 	    if (val == -1)
 	      arm_print_operand (stream, XEXP (x, 1), 0);
 	    else
-- 
GitLab