Ping: PR 22599/target Add checks for illegal x86 asm constraints

Michael Meissner gnu@the-meissners.org
Wed Jan 14 21:05:00 GMT 2009


Andrew pinged me on a patch that I wrote in 2005 when I had started working for
AMD, but at the time I submitted the patch, I was in copyright limbo until AMD
signed the paperwork later in the year.  I evidently forgot all about the
patch.  The original patch applies directly to the current source.  Is this ok
to apply?

This is the patch that I originally did:
http://gcc.gnu.org/bugzilla/attachment.cgi?id=9328

This is a corrected patch that applies against the latest sources.  I did a
quick bootstrap of just C, and a make check, and there were extra errors:

2009-01-14  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).  Reformat a few long
	lines.

--- gcc/config/i386/i386.c.~1~	2009-01-13 11:58:35.000000000 -0500
+++ gcc/config/i386/i386.c	2009-01-14 12:38:47.000000000 -0500
@@ -10834,7 +10834,8 @@ print_operand (FILE *file, rtx x, int co
 		  fputs ("ord", file);
 		  break;
 		default:
-		  gcc_unreachable ();
+		  output_operand_lossage ("operand is not a condition code, invalid operand code 'D'");
+		  return;
 		}
 	    }
 	  else
@@ -10872,7 +10873,8 @@ print_operand (FILE *file, rtx x, int co
 		  fputs ("ord", file);
 		  break;
 		default:
-		  gcc_unreachable ();
+		  output_operand_lossage ("operand is not a condition code, invalid operand code 'D'");
+		  return;
 		}
 	    }
 	  return;
@@ -10894,9 +10896,23 @@ print_operand (FILE *file, rtx x, int co
 #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);
@@ -10909,13 +10925,22 @@ print_operand (FILE *file, rtx x, int co
 	  /* Check to see if argument to %c is really a constant
 	     and not a condition code which needs to be reversed.  */
 	  if (!COMPARISON_P (x))
-	  {
-	    output_operand_lossage ("operand is neither a constant nor a condition code, invalid operand code 'c'");
-	     return;
-	  }
+	    {
+	      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);
@@ -11022,7 +11047,8 @@ print_operand (FILE *file, rtx x, int co
 	      fputs ("une", file);
 	      break;
 	    default:
-	      gcc_unreachable ();
+	      output_operand_lossage ("operand is not a condition code, invalid operand code 'D'");
+	      return;
 	    }
 	  return;
 

-- 
Michael Meissner, IBM
4 Technology Place Drive, MS 2203A, Westford, MA, 01886, USA
meissner@linux.vnet.ibm.com



More information about the Gcc-patches mailing list