]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR middle-end/51768 (ICE with invalid asm goto)
authorJakub Jelinek <jakub@redhat.com>
Thu, 9 Feb 2012 21:35:36 +0000 (22:35 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 9 Feb 2012 21:35:36 +0000 (22:35 +0100)
Backported from mainline
2012-01-05  Jakub Jelinek  <jakub@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.

From-SVN: r184071

gcc/ChangeLog
gcc/stmt.c
gcc/testsuite/ChangeLog
gcc/testsuite/c-c++-common/pr51768.c [new file with mode: 0644]

index a21fe5f49b4985375b863e2de04be079e0f22c72..b71e79facaf3a2f400320039d4488ab58cdb57ce 100644 (file)
@@ -3,6 +3,10 @@
        Backported from mainline
        2012-01-05  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/51768
+       * stmt.c (check_unique_operand_names): Don't ICE during error
+       reporting if i is from labels chain.
+
        PR middle-end/44777
        * profile.c (branch_prob): Split bbs that have exit edge
        and need a fake entry edge too.
index 5f9c234defd69470764b1beba3421a3353fb8687..afa4e6961ec3cdec77210e49312ec955e2157625 100644 (file)
@@ -1232,11 +1232,11 @@ check_operand_nalternatives (tree outputs, tree inputs)
 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;
 
@@ -1247,7 +1247,7 @@ check_unique_operand_names (tree outputs, tree inputs, tree labels)
 
   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;
 
@@ -1261,7 +1261,7 @@ check_unique_operand_names (tree outputs, tree inputs, tree labels)
 
   for (i = labels; i ; i = TREE_CHAIN (i))
     {
-      tree i_name = TREE_PURPOSE (i);
+      i_name = TREE_PURPOSE (i);
       if (! i_name)
        continue;
 
@@ -1276,8 +1276,7 @@ check_unique_operand_names (tree outputs, tree inputs, tree labels)
   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;
 }
 
index 1324a9c41d4a38b62de87d029b838f534c9a5e05..9f0b74bd688398c12fd302754f15d9d30d1bff89 100644 (file)
@@ -3,6 +3,9 @@
        Backported from mainline
        2012-01-05  Jakub Jelinek  <jakub@redhat.com>
 
+       PR middle-end/51768
+       * c-c++-common/pr51768.c: New test.
+
        PR middle-end/44777
        * gcc.dg/tree-prof/pr44777.c: New test.
 
diff --git a/gcc/testsuite/c-c++-common/pr51768.c b/gcc/testsuite/c-c++-common/pr51768.c
new file mode 100644 (file)
index 0000000..082594c
--- /dev/null
@@ -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" } */
+}