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 for bug 22599


This patch adds extra checks so if you use some asm constructs for the wrong
machine, the compiler doesn't segfault.  Unfortunately, my paperwork is in
limbo right now in terms of copyright assignments, but it is a fairly trivial
patch.

2005-07-21  Michael Meissner  <gnu@the-meissners.org>

	* i386.c (print_operand): Add tests for 'D', 'C', 'F', 'f' to make
	sure the insn is a conditional test (bug 22599).

*** gcc/config/i386/i386.c.~1.843.~	2005-07-18 16:35:44.000000000 -0400
--- gcc/config/i386/i386.c	2005-07-21 17:16:09.000000000 -0400
*************** print_operand (FILE *file, rtx x, int co
*** 6772,6778 ****
  	      fputs ("ord", file);
  	      break;
  	    default:
! 	      gcc_unreachable ();
  	    }
  	  return;
  	case 'O':
--- 6772,6779 ----
  	      fputs ("ord", file);
  	      break;
  	    default:
! 	      output_operand_lossage ("operand is not a condition code, invalid operand code 'D'");
! 	      return;
  	    }
  	  return;
  	case 'O':
*************** print_operand (FILE *file, rtx x, int co
*** 6793,6801 ****
--- 6794,6812 ----
  #endif
  	  return;
  	case 'C':
+ 	  if (!COMPARISON_P (x))
+ 	  {
+ 	    output_operand_lossage ("operand is neither a constant nor a condition code, invalid operand code 'C'");
+ 	    return;
+ 	  }
  	  put_condition_code (GET_CODE (x), GET_MODE (XEXP (x, 0)), 0, 0, file);
  	  return;
  	case 'F':
+ 	  if (!COMPARISON_P (x))
+ 	  {
+ 	    output_operand_lossage ("operand is neither a constant nor a condition code, invalid operand code 'F'");
+ 	     return;
+ 	  }
  #ifdef HAVE_AS_IX86_CMOV_SUN_SYNTAX
  	  if (ASSEMBLER_DIALECT == ASM_ATT)
  	    putc ('.', file);
*************** print_operand (FILE *file, rtx x, int co
*** 6810,6820 ****
  	  if (!COMPARISON_P (x))
  	  {
  	    output_operand_lossage ("operand is neither a constant nor a condition code, invalid operand code 'c'");
! 	     return;
  	  }
  	  put_condition_code (GET_CODE (x), GET_MODE (XEXP (x, 0)), 1, 0, file);
  	  return;
  	case 'f':
  #ifdef HAVE_AS_IX86_CMOV_SUN_SYNTAX
  	  if (ASSEMBLER_DIALECT == ASM_ATT)
  	    putc ('.', file);
--- 6821,6836 ----
  	  if (!COMPARISON_P (x))
  	  {
  	    output_operand_lossage ("operand is neither a constant nor a condition code, invalid operand code 'c'");
! 	    return;
  	  }
  	  put_condition_code (GET_CODE (x), GET_MODE (XEXP (x, 0)), 1, 0, file);
  	  return;
  	case 'f':
+ 	  if (!COMPARISON_P (x))
+ 	  {
+ 	    output_operand_lossage ("operand is neither a constant nor a condition code, invalid operand code 'f'");
+ 	    return;
+ 	  }
  #ifdef HAVE_AS_IX86_CMOV_SUN_SYNTAX
  	  if (ASSEMBLER_DIALECT == ASM_ATT)
  	    putc ('.', file);

-- 
Michael Meissner
email: gnu@the-meissners.org
http://www.the-meissners.org


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