re PR middle-end/51768 (ICE with invalid asm goto)
authorJakub Jelinek <jakub@redhat.com>
Thu, 5 Jan 2012 20:18:15 +0000 (21:18 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 5 Jan 2012 20:18:15 +0000 (21:18 +0100)
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: r182921

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

index 9cbe9c0ffb6246fa6d52b043f9d0d8cc2101e19c..2e59648f2fa74a791cee6749cb683d8e9e109c23 100644 (file)
@@ -1,5 +1,9 @@
 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 af6439cd879781243396acd44a035d99c87747d9..93d643a7bf0a8bdfa53fc627cad0c4c58ffc266a 100644 (file)
@@ -1,7 +1,7 @@
 /* Expands front end tree to back end RTL for GCC
    Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997,
    1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
-   2010 Free Software Foundation, Inc.
+   2010, 2011, 2012 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -1253,11 +1253,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;
 
@@ -1268,7 +1268,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;
 
@@ -1282,7 +1282,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;
 
@@ -1297,8 +1297,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 d35dab996b5a791dcc757ed4c8914b0f16a0906f..5341574befe099b904ccba1a545271e3098cceb6 100644 (file)
@@ -1,5 +1,8 @@
 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" } */
+}