[llvm-branch-commits] [cfe-branch] r127752 - in /cfe/branches/release_29: ./ include/clang/Parse/Parser.h include/clang/Sema/IdentifierResolver.h lib/Parse/ParseCXXInlineMethods.cpp lib/Parse/ParseExpr.cpp lib/Parse/ParseObjc.cpp lib/Parse/ParseStmt.cpp lib/Parse/Parser.cpp lib/Sema/IdentifierResolver.cpp lib/Sema/SemaDecl.cpp test/SemaCXX/goto.cpp test/SemaCXX/warn-unreachable.cpp test/SemaObjCXX/goto.mm
Bill Wendling
isanbard at gmail.com
Wed Mar 16 12:56:32 PDT 2011
Author: void
Date: Wed Mar 16 14:56:32 2011
New Revision: 127752
URL: http://llvm.org/viewvc/llvm-project?rev=127752&view=rev
Log:
--- Merging r127623 into '.':
A test/SemaCXX/goto.cpp
U include/clang/Sema/IdentifierResolver.h
U lib/Sema/SemaDecl.cpp
U lib/Sema/IdentifierResolver.cpp
--- Merging r127737 into '.':
U test/SemaCXX/goto.cpp
G include/clang/Sema/IdentifierResolver.h
G lib/Sema/SemaDecl.cpp
G lib/Sema/IdentifierResolver.cpp
--- Merging r127738 into '.':
A test/SemaObjCXX/goto.mm
G test/SemaCXX/goto.cpp
U include/clang/Parse/Parser.h
U lib/Parse/ParseObjc.cpp
U lib/Parse/ParseExpr.cpp
U lib/Parse/ParseCXXInlineMethods.cpp
U lib/Parse/ParseStmt.cpp
U lib/Parse/Parser.cpp
Added:
cfe/branches/release_29/test/SemaCXX/goto.cpp
- copied, changed from r127623, cfe/trunk/test/SemaCXX/goto.cpp
cfe/branches/release_29/test/SemaObjCXX/goto.mm
- copied unchanged from r127738, cfe/trunk/test/SemaObjCXX/goto.mm
Modified:
cfe/branches/release_29/ (props changed)
cfe/branches/release_29/include/clang/Parse/Parser.h
cfe/branches/release_29/include/clang/Sema/IdentifierResolver.h
cfe/branches/release_29/lib/Parse/ParseCXXInlineMethods.cpp
cfe/branches/release_29/lib/Parse/ParseExpr.cpp
cfe/branches/release_29/lib/Parse/ParseObjc.cpp
cfe/branches/release_29/lib/Parse/ParseStmt.cpp
cfe/branches/release_29/lib/Parse/Parser.cpp
cfe/branches/release_29/lib/Sema/IdentifierResolver.cpp
cfe/branches/release_29/lib/Sema/SemaDecl.cpp
cfe/branches/release_29/test/SemaCXX/warn-unreachable.cpp (props changed)
Propchange: cfe/branches/release_29/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Mar 16 14:56:32 2011
@@ -1,2 +1,2 @@
-/cfe/trunk:127283,127308,127326,127373,127460,127512,127541,127543,127563
+/cfe/trunk:127283,127308,127326,127373,127460,127512,127541,127543,127563,127623,127737-127738
/cfe/trunk/test/SemaTemplate:126920
Modified: cfe/branches/release_29/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_29/include/clang/Parse/Parser.h?rev=127752&r1=127751&r2=127752&view=diff
==============================================================================
--- cfe/branches/release_29/include/clang/Parse/Parser.h (original)
+++ cfe/branches/release_29/include/clang/Parse/Parser.h Wed Mar 16 14:56:32 2011
@@ -1271,8 +1271,8 @@
SourceLocation *DeclEnd = 0);
Decl *ParseDeclarationAfterDeclarator(Declarator &D,
const ParsedTemplateInfo &TemplateInfo = ParsedTemplateInfo());
- Decl *ParseFunctionStatementBody(Decl *Decl);
- Decl *ParseFunctionTryBlock(Decl *Decl);
+ Decl *ParseFunctionStatementBody(Decl *Decl, ParseScope &BodyScope);
+ Decl *ParseFunctionTryBlock(Decl *Decl, ParseScope &BodyScope);
/// \brief When in code-completion, skip parsing of the function/method body
/// unless the body contains the code-completion point.
Modified: cfe/branches/release_29/include/clang/Sema/IdentifierResolver.h
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_29/include/clang/Sema/IdentifierResolver.h?rev=127752&r1=127751&r2=127752&view=diff
==============================================================================
--- cfe/branches/release_29/include/clang/Sema/IdentifierResolver.h (original)
+++ cfe/branches/release_29/include/clang/Sema/IdentifierResolver.h Wed Mar 16 14:56:32 2011
@@ -53,6 +53,11 @@
/// declaration was not found, returns false.
bool ReplaceDecl(NamedDecl *Old, NamedDecl *New);
+ /// \brief Insert the given declaration at the given position in the list.
+ void InsertDecl(DeclsTy::iterator Pos, NamedDecl *D) {
+ Decls.insert(Pos, D);
+ }
+
private:
DeclsTy Decls;
};
@@ -166,6 +171,10 @@
/// (and, therefore, replaced).
bool ReplaceDecl(NamedDecl *Old, NamedDecl *New);
+ /// \brief Insert the given declaration after the given iterator
+ /// position.
+ void InsertDeclAfter(iterator Pos, NamedDecl *D);
+
/// \brief Link the declaration into the chain of declarations for
/// the given identifier.
///
Modified: cfe/branches/release_29/lib/Parse/ParseCXXInlineMethods.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_29/lib/Parse/ParseCXXInlineMethods.cpp?rev=127752&r1=127751&r2=127752&view=diff
==============================================================================
--- cfe/branches/release_29/lib/Parse/ParseCXXInlineMethods.cpp (original)
+++ cfe/branches/release_29/lib/Parse/ParseCXXInlineMethods.cpp Wed Mar 16 14:56:32 2011
@@ -261,7 +261,7 @@
Actions.ActOnStartOfFunctionDef(getCurScope(), LM.D);
if (Tok.is(tok::kw_try)) {
- ParseFunctionTryBlock(LM.D);
+ ParseFunctionTryBlock(LM.D, FnScope);
assert(!PP.getSourceManager().isBeforeInTranslationUnit(origLoc,
Tok.getLocation()) &&
"ParseFunctionTryBlock went over the cached tokens!");
@@ -276,13 +276,14 @@
// Error recovery.
if (!Tok.is(tok::l_brace)) {
+ FnScope.Exit();
Actions.ActOnFinishFunctionBody(LM.D, 0);
return;
}
} else
Actions.ActOnDefaultCtorInitializers(LM.D);
- ParseFunctionStatementBody(LM.D);
+ ParseFunctionStatementBody(LM.D, FnScope);
if (Tok.getLocation() != origLoc) {
// Due to parsing error, we either went over the cached tokens or
Modified: cfe/branches/release_29/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_29/lib/Parse/ParseExpr.cpp?rev=127752&r1=127751&r2=127752&view=diff
==============================================================================
--- cfe/branches/release_29/lib/Parse/ParseExpr.cpp (original)
+++ cfe/branches/release_29/lib/Parse/ParseExpr.cpp Wed Mar 16 14:56:32 2011
@@ -1940,6 +1940,7 @@
}
StmtResult Stmt(ParseCompoundStatementBody());
+ BlockScope.Exit();
if (!Stmt.isInvalid())
Result = Actions.ActOnBlockStmtExpr(CaretLoc, Stmt.take(), getCurScope());
else
Modified: cfe/branches/release_29/lib/Parse/ParseObjc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_29/lib/Parse/ParseObjc.cpp?rev=127752&r1=127751&r2=127752&view=diff
==============================================================================
--- cfe/branches/release_29/lib/Parse/ParseObjc.cpp (original)
+++ cfe/branches/release_29/lib/Parse/ParseObjc.cpp Wed Mar 16 14:56:32 2011
@@ -1717,9 +1717,12 @@
// specified Declarator for the method.
Actions.ActOnStartOfObjCMethodDef(getCurScope(), MDecl);
- if (PP.isCodeCompletionEnabled())
- if (trySkippingFunctionBodyForCodeCompletion())
+ if (PP.isCodeCompletionEnabled()) {
+ if (trySkippingFunctionBodyForCodeCompletion()) {
+ BodyScope.Exit();
return Actions.ActOnFinishFunctionBody(MDecl, 0);
+ }
+ }
StmtResult FnBody(ParseCompoundStatementBody());
@@ -1728,12 +1731,11 @@
FnBody = Actions.ActOnCompoundStmt(BraceLoc, BraceLoc,
MultiStmtArg(Actions), false);
- // TODO: Pass argument information.
- Actions.ActOnFinishFunctionBody(MDecl, FnBody.take());
-
// Leave the function body scope.
BodyScope.Exit();
-
+
+ // TODO: Pass argument information.
+ Actions.ActOnFinishFunctionBody(MDecl, FnBody.take());
return MDecl;
}
Modified: cfe/branches/release_29/lib/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_29/lib/Parse/ParseStmt.cpp?rev=127752&r1=127751&r2=127752&view=diff
==============================================================================
--- cfe/branches/release_29/lib/Parse/ParseStmt.cpp (original)
+++ cfe/branches/release_29/lib/Parse/ParseStmt.cpp Wed Mar 16 14:56:32 2011
@@ -1522,14 +1522,17 @@
return true;
}
-Decl *Parser::ParseFunctionStatementBody(Decl *Decl) {
+Decl *Parser::ParseFunctionStatementBody(Decl *Decl, ParseScope &BodyScope) {
assert(Tok.is(tok::l_brace));
SourceLocation LBraceLoc = Tok.getLocation();
- if (PP.isCodeCompletionEnabled())
- if (trySkippingFunctionBodyForCodeCompletion())
+ if (PP.isCodeCompletionEnabled()) {
+ if (trySkippingFunctionBodyForCodeCompletion()) {
+ BodyScope.Exit();
return Actions.ActOnFinishFunctionBody(Decl, 0);
-
+ }
+ }
+
PrettyDeclStackTraceEntry CrashInfo(Actions, Decl, LBraceLoc,
"parsing function body");
@@ -1543,6 +1546,7 @@
FnBody = Actions.ActOnCompoundStmt(LBraceLoc, LBraceLoc,
MultiStmtArg(Actions), false);
+ BodyScope.Exit();
return Actions.ActOnFinishFunctionBody(Decl, FnBody.take());
}
@@ -1551,7 +1555,7 @@
/// function-try-block:
/// 'try' ctor-initializer[opt] compound-statement handler-seq
///
-Decl *Parser::ParseFunctionTryBlock(Decl *Decl) {
+Decl *Parser::ParseFunctionTryBlock(Decl *Decl, ParseScope &BodyScope) {
assert(Tok.is(tok::kw_try) && "Expected 'try'");
SourceLocation TryLoc = ConsumeToken();
@@ -1562,9 +1566,12 @@
if (Tok.is(tok::colon))
ParseConstructorInitializer(Decl);
- if (PP.isCodeCompletionEnabled())
- if (trySkippingFunctionBodyForCodeCompletion())
+ if (PP.isCodeCompletionEnabled()) {
+ if (trySkippingFunctionBodyForCodeCompletion()) {
+ BodyScope.Exit();
return Actions.ActOnFinishFunctionBody(Decl, 0);
+ }
+ }
SourceLocation LBraceLoc = Tok.getLocation();
StmtResult FnBody(ParseCXXTryBlockCommon(TryLoc));
@@ -1574,6 +1581,7 @@
FnBody = Actions.ActOnCompoundStmt(LBraceLoc, LBraceLoc,
MultiStmtArg(Actions), false);
+ BodyScope.Exit();
return Actions.ActOnFinishFunctionBody(Decl, FnBody.take());
}
Modified: cfe/branches/release_29/lib/Parse/Parser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_29/lib/Parse/Parser.cpp?rev=127752&r1=127751&r2=127752&view=diff
==============================================================================
--- cfe/branches/release_29/lib/Parse/Parser.cpp (original)
+++ cfe/branches/release_29/lib/Parse/Parser.cpp Wed Mar 16 14:56:32 2011
@@ -801,7 +801,7 @@
D.getMutableDeclSpec().abort();
if (Tok.is(tok::kw_try))
- return ParseFunctionTryBlock(Res);
+ return ParseFunctionTryBlock(Res, BodyScope);
// If we have a colon, then we're probably parsing a C++
// ctor-initializer.
@@ -810,13 +810,14 @@
// Recover from error.
if (!Tok.is(tok::l_brace)) {
+ BodyScope.Exit();
Actions.ActOnFinishFunctionBody(Res, 0);
return Res;
}
} else
Actions.ActOnDefaultCtorInitializers(Res);
- return ParseFunctionStatementBody(Res);
+ return ParseFunctionStatementBody(Res, BodyScope);
}
/// ParseKNRParamDeclarations - Parse 'declaration-list[opt]' which provides
Modified: cfe/branches/release_29/lib/Sema/IdentifierResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_29/lib/Sema/IdentifierResolver.cpp?rev=127752&r1=127751&r2=127752&view=diff
==============================================================================
--- cfe/branches/release_29/lib/Sema/IdentifierResolver.cpp (original)
+++ cfe/branches/release_29/lib/Sema/IdentifierResolver.cpp Wed Mar 16 14:56:32 2011
@@ -168,6 +168,29 @@
IDI->AddDecl(D);
}
+void IdentifierResolver::InsertDeclAfter(iterator Pos, NamedDecl *D) {
+ DeclarationName Name = D->getDeclName();
+ void *Ptr = Name.getFETokenInfo<void>();
+
+ if (Pos == iterator() || isDeclPtr(Ptr)) {
+ // Simple case: insert at the end of the list (which is the
+ // end of the stored vector).
+ AddDecl(D);
+ return;
+ }
+
+ if (IdentifierInfo *II = Name.getAsIdentifierInfo())
+ II->setIsFromAST(false);
+
+ // General case: insert the declaration at the appropriate point in the
+ // list, which already has at least two elements.
+ IdDeclInfo *IDI = toIdDeclInfo(Ptr);
+ if (Pos.isIterator()) {
+ IDI->InsertDecl(Pos.getIterator() + 1, D);
+ } else
+ IDI->InsertDecl(IDI->decls_begin(), D);
+}
+
/// RemoveDecl - Unlink the decl from its shadowed decl chain.
/// The decl must already be part of the decl chain.
void IdentifierResolver::RemoveDecl(NamedDecl *D) {
Modified: cfe/branches/release_29/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_29/lib/Sema/SemaDecl.cpp?rev=127752&r1=127751&r2=127752&view=diff
==============================================================================
--- cfe/branches/release_29/lib/Sema/SemaDecl.cpp (original)
+++ cfe/branches/release_29/lib/Sema/SemaDecl.cpp Wed Mar 16 14:56:32 2011
@@ -493,7 +493,24 @@
}
S->AddDecl(D);
- IdResolver.AddDecl(D);
+
+ if (isa<LabelDecl>(D) && !cast<LabelDecl>(D)->isGnuLocal()) {
+ // Implicitly-generated labels may end up getting generated in an order that
+ // 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();
+ if (IDC == CurContext) {
+ if (!S->isDeclScope(*I))
+ continue;
+ } else if (IDC->Encloses(CurContext))
+ break;
+ }
+
+ IdResolver.InsertDeclAfter(I, D);
+ } else {
+ IdResolver.AddDecl(D);
+ }
}
bool Sema::isDeclInScope(NamedDecl *&D, DeclContext *Ctx, Scope *S,
Copied: cfe/branches/release_29/test/SemaCXX/goto.cpp (from r127623, cfe/trunk/test/SemaCXX/goto.cpp)
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_29/test/SemaCXX/goto.cpp?p2=cfe/branches/release_29/test/SemaCXX/goto.cpp&p1=cfe/trunk/test/SemaCXX/goto.cpp&r1=127623&r2=127752&rev=127752&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/goto.cpp (original)
+++ cfe/branches/release_29/test/SemaCXX/goto.cpp Wed Mar 16 14:56:32 2011
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fblocks %s
// PR9463
double *end;
@@ -16,3 +16,54 @@
void g() {
end = 1; // expected-error{{assigning to 'double *' from incompatible type 'int'}}
}
+
+void h(int end) {
+ {
+ goto end; // expected-error{{use of undeclared label 'end'}}
+ }
+}
+
+void h2(int end) {
+ {
+ __label__ end;
+ goto end;
+
+ end:
+ ::end = 0;
+ }
+ end:
+ end = 1;
+}
+
+class X {
+public:
+ X();
+};
+
+void rdar9135994()
+{
+X:
+ goto X;
+}
+
+namespace PR9495 {
+ struct NonPOD { NonPOD(); ~NonPOD(); };
+
+ void f(bool b) {
+ NonPOD np;
+ if (b) {
+ goto undeclared; // expected-error{{use of undeclared label 'undeclared'}}
+ }
+ }
+
+ void g() {
+ (void)^(bool b){
+ NonPOD np;
+ if (b) {
+ goto undeclared; // expected-error{{use of undeclared label 'undeclared'}}
+ }
+ };
+ }
+}
+
+
Propchange: cfe/branches/release_29/test/SemaCXX/warn-unreachable.cpp
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Mar 16 14:56:32 2011
@@ -1 +1 @@
-/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,127283,127308,127326,127373,127460,127512,127541,127543,127563
+/cfe/trunk/test/SemaCXX/warn-unreachable.cpp:121961,127283,127308,127326,127373,127460,127512,127541,127543,127563,127623,127737-127738
More information about the llvm-branch-commits
mailing list