From: Douglas Gregor Date: Thu, 24 Mar 2011 14:35:16 +0000 (+0000) Subject: Minor fix in the injection of labels, since we want to look at the redeclaration... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1d2de76c75fc1ac870c6df84c5368206c00d9a5e;p=clang Minor fix in the injection of labels, since we want to look at the redeclaration context of each declaration in the identifier chain. Should fix Linux self-host git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@128210 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index a6c154338f..6f98461f44 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -500,7 +500,7 @@ void Sema::PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext) { // isn't strictly lexical, which breaks name lookup. Be careful to insert // the label at the appropriate place in the identifier chain. for (I = IdResolver.begin(D->getDeclName()); I != IEnd; ++I) { - DeclContext *IDC = (*I)->getLexicalDeclContext(); + DeclContext *IDC = (*I)->getLexicalDeclContext()->getRedeclContext(); if (IDC == CurContext) { if (!S->isDeclScope(*I)) continue; diff --git a/test/SemaCXX/goto.cpp b/test/SemaCXX/goto.cpp index b2b1e6f391..d8d5ec51f6 100644 --- a/test/SemaCXX/goto.cpp +++ b/test/SemaCXX/goto.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wall -fblocks %s // PR9463 double *end; @@ -57,7 +57,7 @@ void h2(int end) { end: ::end = 0; } - end: + end: // expected-warning{{unused label 'end'}} end = 1; } @@ -92,4 +92,14 @@ namespace PR9495 { } } +extern "C" { + void exit(int); +} +void f() { + { + goto exit; + } + exit: + return; +}