Hi!

The following testcase ICEs, because we encounter gcc_unreachable during
inline-asm operand modifier processing.  The usual way out of this is
to use output_operand_lossage which will ICE if not in inline-asm and error
otherwise.  Furthermore, I found a typo in the documentation.
Acked by Jim in the PR, committed to trunk.

2020-01-09  Jakub Jelinek  <ja...@redhat.com>

        PR inline-asm/93202
        * config/riscv/riscv.c (riscv_print_operand_reloc): Use
        output_operand_lossage instead of gcc_unreachable.
        * doc/md.texi (riscv f constraint): Fix typo.

        * gcc.target/riscv/pr93202.c: New test.

--- gcc/config/riscv/riscv.c.jj 2020-01-01 12:16:09.322287585 +0100
+++ gcc/config/riscv/riscv.c    2020-01-08 18:50:02.872159743 +0100
@@ -3188,7 +3188,8 @@ riscv_print_operand_reloc (FILE *file, r
        break;
 
       default:
-       gcc_unreachable ();
+       output_operand_lossage ("invalid use of '%%%c'", hi_reloc ? 'h' : 'R');
+       return;
     }
 
   fprintf (file, "%s(", reloc);
--- gcc/doc/md.texi.jj  2020-01-07 08:01:27.260543512 +0100
+++ gcc/doc/md.texi     2020-01-08 18:40:08.767065881 +0100
@@ -3518,7 +3518,7 @@ The @code{X} register.
 @table @code
 
 @item f
-A floating-point register (if availiable).
+A floating-point register (if available).
 
 @item I
 An I-type 12-bit signed immediate.
--- gcc/testsuite/gcc.target/riscv/pr93202.c.jj 2020-01-08 18:51:59.802407218 
+0100
+++ gcc/testsuite/gcc.target/riscv/pr93202.c    2020-01-08 18:51:32.810811762 
+0100
@@ -0,0 +1,10 @@
+/* PR inline-asm/93202 */
+/* { dg-do compile { target fpic } } */
+/* { dg-options "-fpic" } */
+
+void
+foo (void)
+{
+  asm volatile ("%h0" :: "i" (&foo));  /* { dg-error "invalid use of '%h'" } */
+  asm volatile ("%R0" :: "i" (&foo));  /* { dg-error "invalid use of '%R'" } */
+}

        Jakub

Reply via email to