Hi!

We use the same goto label for duplicate names of outputs/inputs/labels,
but unlike outputs/inputs names where the STRING_CSTs are at
TREE_PURPOSE (TREE_PURPOSE (i)), the STRING_CSTs for labels are
at TREE_PURPOSE (i), thus if we need to report duplicate labels
(either duplicate to some input/output or to another label name),
we ICE.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk?

2012-01-05  Jakub Jelinek  <ja...@redhat.com>

        PR middle-end/51768
        * stmt.c (check_unique_operand_names): Don't ICE during error
        reporting if i is from labels chain.

        * c-c++-common/pr51768.c: New test.

--- gcc/stmt.c.jj       2011-10-12 20:28:20.000000000 +0200
+++ gcc/stmt.c  2012-01-05 16:33:35.025410543 +0100
@@ -1253,11 +1253,11 @@ check_operand_nalternatives (tree output
 static bool
 check_unique_operand_names (tree outputs, tree inputs, tree labels)
 {
-  tree i, j;
+  tree i, j, i_name = NULL_TREE;
 
   for (i = outputs; i ; i = TREE_CHAIN (i))
     {
-      tree i_name = TREE_PURPOSE (TREE_PURPOSE (i));
+      i_name = TREE_PURPOSE (TREE_PURPOSE (i));
       if (! i_name)
        continue;
 
@@ -1268,7 +1268,7 @@ check_unique_operand_names (tree outputs
 
   for (i = inputs; i ; i = TREE_CHAIN (i))
     {
-      tree i_name = TREE_PURPOSE (TREE_PURPOSE (i));
+      i_name = TREE_PURPOSE (TREE_PURPOSE (i));
       if (! i_name)
        continue;
 
@@ -1282,7 +1282,7 @@ check_unique_operand_names (tree outputs
 
   for (i = labels; i ; i = TREE_CHAIN (i))
     {
-      tree i_name = TREE_PURPOSE (i);
+      i_name = TREE_PURPOSE (i);
       if (! i_name)
        continue;
 
@@ -1297,8 +1297,7 @@ check_unique_operand_names (tree outputs
   return true;
 
  failure:
-  error ("duplicate asm operand name %qs",
-        TREE_STRING_POINTER (TREE_PURPOSE (TREE_PURPOSE (i))));
+  error ("duplicate asm operand name %qs", TREE_STRING_POINTER (i_name));
   return false;
 }
 
--- gcc/testsuite/c-c++-common/pr51768.c.jj     2012-01-05 16:50:19.665528010 
+0100
+++ gcc/testsuite/c-c++-common/pr51768.c        2012-01-05 16:49:54.000000000 
+0100
@@ -0,0 +1,25 @@
+/* PR middle-end/51768 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void
+foo (void)
+{
+  asm goto ("" : : : : lab, lab, lab2, lab);   /* { dg-error "duplicate asm 
operand name" } */
+lab:;
+lab2:;
+}
+
+void
+bar (void)
+{
+  asm goto ("" : : [lab] "i" (0) : : lab);     /* { dg-error "duplicate asm 
operand name" } */
+lab:;
+}
+
+void
+baz (void)
+{
+  int x;
+  asm ("" : [lab] "=r" (x) : [lab] "r" (x));   /* { dg-error "duplicate asm 
operand name" } */
+}

        Jakub

Reply via email to