]> gcc.gnu.org Git - gcc.git/commitdiff
i386: Fix ICE in ix86_print_opreand_address [PR 102761]
authorUros Bizjak <ubizjak@gmail.com>
Mon, 18 Oct 2021 15:03:28 +0000 (17:03 +0200)
committerUros Bizjak <ubizjak@gmail.com>
Mon, 18 Oct 2021 21:01:33 +0000 (23:01 +0200)
2021-10-18  Uroš Bizjak  <ubizjak@gmail.com>

PR target/102761

gcc/ChangeLog:

* config/i386/i386.c (ix86_print_operand_address):
Error out for non-address_operand asm operands.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr102761.c: New test.

gcc/config/i386/i386.c
gcc/testsuite/gcc.target/i386/pr102761.c [new file with mode: 0644]

index fa80daba5231afbe5d6d75860b626c0424423f2a..42c47d2b12b1c4dcb15adac79e823307ba634462 100644 (file)
@@ -13767,7 +13767,10 @@ ix86_print_operand_address_as (FILE *file, rtx addr,
 static void
 ix86_print_operand_address (FILE *file, machine_mode /*mode*/, rtx addr)
 {
-  ix86_print_operand_address_as (file, addr, ADDR_SPACE_GENERIC, false);
+  if (this_is_asm_operands && ! address_operand (addr, VOIDmode))
+    output_operand_lossage ("invalid constraints for operand");
+  else
+    ix86_print_operand_address_as (file, addr, ADDR_SPACE_GENERIC, false);
 }
 
 /* Implementation of TARGET_ASM_OUTPUT_ADDR_CONST_EXTRA.  */
diff --git a/gcc/testsuite/gcc.target/i386/pr102761.c b/gcc/testsuite/gcc.target/i386/pr102761.c
new file mode 100644 (file)
index 0000000..58ff27e
--- /dev/null
@@ -0,0 +1,11 @@
+/* PR target/102761 */
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+int foo (void);
+
+void
+bar (void)
+{
+  asm volatile ("%a0" : : "X"(foo () ? 2 : 1)); /* { dg-error "invalid constraints for operand" } */
+}
This page took 0.102891 seconds and 5 git commands to generate.