This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fail on invalid operand code in mips_print_operand


This has bitten me when I added the "m" operand code.  I was merging a patch
and forgot to update mips_print_operand.  mips_print_operand happily printed
the original constant value rather than the value minus one.

The patch below adds more checking to prevent this in the future.

Regtested on mipsisa64r2-elfoabi{,-mips16}.

OK to install?

Adam


	* config/mips/mips.c (mips_print_operand) <REG, MEM, default>:
	Check for invalid values of LETTER.

Index: mips.c
===================================================================
--- mips.c	(revision 147359)
+++ mips.c	(working copy)
@@ -7292,6 +7292,8 @@ mips_print_operand (FILE *file, rtx op, 
 		|| (letter == 'L' && TARGET_BIG_ENDIAN)
 		|| letter == 'D')
 	      regno++;
+	    else if (letter && letter != 'z' && letter != 'M' && letter != 'L')
+	      output_operand_lossage ("invalid use of '%%%c'", letter);
 	    /* We need to print $0 .. $31 for COP0 registers.  */
 	    if (COP0_REG_P (regno))
 	      fprintf (file, "$%s", &reg_names[regno][4]);
@@ -7303,6 +7305,8 @@ mips_print_operand (FILE *file, rtx op, 
 	case MEM:
 	  if (letter == 'D')
 	    output_address (plus_constant (XEXP (op, 0), 4));
+	  else if (letter)
+	    output_operand_lossage ("invalid use of '%%%c'", letter);
 	  else
 	    output_address (XEXP (op, 0));
 	  break;
@@ -7310,6 +7314,8 @@ mips_print_operand (FILE *file, rtx op, 
 	default:
 	  if (letter == 'z' && op == CONST0_RTX (GET_MODE (op)))
 	    fputs (reg_names[GP_REG_FIRST], file);
+	  else if (letter && letter != 'z')
+	    output_operand_lossage ("invalid use of '%%%c'", letter);
 	  else if (CONST_GP_P (op))
 	    fputs (reg_names[GLOBAL_POINTER_REGNUM], file);
 	  else


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]