2017-04-20  Uros Bizjak  <ubiz...@gmail.com>

    PR target/79804
    * config/i386/i386.c (print_reg): Remove assert for disalowed
    regno values, call output_operand_lossage instead.

testsuite/ChangeLog:

2017-04-20  Uros Bizjak  <ubiz...@gmail.com>

    PR target/79804
    * gcc.target/i386/pr79804.c: New test.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline SVN.

Uros.
Index: config/i386/i386.c
===================================================================
--- config/i386/i386.c  (revision 246382)
+++ config/i386/i386.c  (working copy)
@@ -17637,13 +17637,17 @@ print_reg (rtx x, int code, FILE *file)
 
   regno = REGNO (x);
 
-  gcc_assert (regno != ARG_POINTER_REGNUM
-             && regno != FRAME_POINTER_REGNUM
-             && regno != FPSR_REG
-             && regno != FPCR_REG);
-
-  if (regno == FLAGS_REG)
+  if (regno == ARG_POINTER_REGNUM
+      || regno == FRAME_POINTER_REGNUM
+      || regno == FPSR_REG
+      || regno == FPCR_REG)
     {
+      output_operand_lossage
+       ("invalid use of register '%s'", reg_names[regno]);
+      return;
+    }
+  else if (regno == FLAGS_REG)
+    {
       output_operand_lossage ("invalid use of asm flag output");
       return;
     }
Index: testsuite/gcc.target/i386/pr79804.c
===================================================================
--- testsuite/gcc.target/i386/pr79804.c (nonexistent)
+++ testsuite/gcc.target/i386/pr79804.c (working copy)
@@ -0,0 +1,10 @@
+/* PR target/79804 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void foo (void)
+{
+  register int r20 asm ("20");
+
+  asm volatile ("# %0" : "=r"(r20));  /* { dg-error "invalid use of register" 
} */
+}

Reply via email to