diff options
author | Richard Earnshaw <erich@gnu.org> | 1994-10-01 10:58:44 +0000 |
---|---|---|
committer | Richard Earnshaw <erich@gnu.org> | 1994-10-01 10:58:44 +0000 |
commit | a784882b53df7bd2261d22524bc1d264f5dc9a62 (patch) | |
tree | e72045f9580f85523762244d156df73fc64a89fe | |
parent | b5eda7762d76faa97e4d54092ad5f1c5c0d64e55 (diff) | |
download | gcc-a784882b53df7bd2261d22524bc1d264f5dc9a62.zip gcc-a784882b53df7bd2261d22524bc1d264f5dc9a62.tar.gz gcc-a784882b53df7bd2261d22524bc1d264f5dc9a62.tar.bz2 |
(shadow_label): Emit an error if the label is already
declared at this label scope.
From-SVN: r8191
-rw-r--r-- | gcc/c-decl.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/gcc/c-decl.c b/gcc/c-decl.c index 5779633..fa16ad7 100644 --- a/gcc/c-decl.c +++ b/gcc/c-decl.c @@ -2440,6 +2440,21 @@ shadow_label (name) if (decl != 0) { + register tree dup; + + /* Check to make sure that the label hasn't already been declared + at this label scope */ + for (dup = named_labels; dup; dup = TREE_CHAIN (dup)) + if (TREE_VALUE (dup) == decl) + { + error ("duplicate label declaration `%s'", + IDENTIFIER_POINTER (name)); + error_with_decl (TREE_VALUE (dup), + "this is a previous declaration"); + /* Just use the previous declaration. */ + return lookup_label (name); + } + shadowed_labels = tree_cons (NULL_TREE, decl, shadowed_labels); IDENTIFIER_LABEL_VALUE (name) = decl = 0; } |