From 5b23c323765211ac043bafec8200bf03eacab8c2 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Thu, 9 Feb 2012 18:21:15 +0100 Subject: [PATCH] backport: re PR middle-end/51768 (ICE with invalid asm goto) Backported from mainline 2012-01-05 Jakub Jelinek 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: r184054 --- gcc/ChangeLog | 4 ++++ gcc/stmt.c | 11 +++++------ gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/c-c++-common/pr51768.c | 25 +++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 gcc/testsuite/c-c++-common/pr51768.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 07e79e9e22a8..6f1469345b0f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -3,6 +3,10 @@ Backported from mainline 2012-01-05 Jakub Jelinek + 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. diff --git a/gcc/stmt.c b/gcc/stmt.c index b65c6db4642d..82ce350f8faf 100644 --- a/gcc/stmt.c +++ b/gcc/stmt.c @@ -1252,11 +1252,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; @@ -1267,7 +1267,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; @@ -1281,7 +1281,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; @@ -1296,8 +1296,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; } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 656579ea4774..706ee801a131 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -3,6 +3,9 @@ Backported from mainline 2012-01-05 Jakub Jelinek + 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 index 000000000000..082594ccad7a --- /dev/null +++ b/gcc/testsuite/c-c++-common/pr51768.c @@ -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" } */ +} -- 2.47.2