diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-04-27 05:41:15 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-04-27 05:41:15 +0000 |
commit | d9d75e57dfa22366c0379c92beac1db82db34e9a (patch) | |
tree | 534e71d8fd4a668648d97c35209349d8f0fa414f /lib/Parse/ParseStmt.cpp | |
parent | 6b4f567109d76ce1f1de289554e35f2a7bbeff6b (diff) |
Simplify the parser's handling of Sema::ClassifyName() for types, by
creating a type-annotation token rather than jumping into the
declaration parsing.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130293 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseStmt.cpp')
-rw-r--r-- | lib/Parse/ParseStmt.cpp | 53 |
1 files changed, 1 insertions, 52 deletions
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp index 5138cc1595..28be864bdf 100644 --- a/lib/Parse/ParseStmt.cpp +++ b/lib/Parse/ParseStmt.cpp @@ -114,7 +114,6 @@ Retry: } if (Next.isNot(tok::coloncolon)) { - // FIXME: Temporarily enable this code only for C. CXXScopeSpec SS; IdentifierInfo *Name = Tok.getIdentifierInfo(); SourceLocation NameLoc = Tok.getLocation(); @@ -147,63 +146,13 @@ Retry: // we're in a syntactic context we haven't handled yet. break; - case Sema::NC_Type: { - // We have a type. In C, this means that we have a declaration. - if (!getLang().CPlusPlus) { - ParsedType Type = Classification.getType(); - const char *PrevSpec = 0; - unsigned DiagID; - ConsumeToken(); // the identifier - ParsingDeclSpec DS(*this); - DS.takeAttributesFrom(attrs); - DS.SetTypeSpecType(DeclSpec::TST_typename, NameLoc, PrevSpec, DiagID, - Type); - DS.SetRangeStart(NameLoc); - DS.SetRangeEnd(NameLoc); - - // In Objective-C, check whether this is the start of a class message - // send that is missing an opening square bracket ('['). - if (getLang().ObjC1 && Tok.is(tok::identifier) && - Type.get()->isObjCObjectOrInterfaceType() && - isColonOrRSquareBracket(NextToken())) { - // Fake up a Declarator to use with ActOnTypeName. - Declarator DeclaratorInfo(DS, Declarator::TypeNameContext); - TypeResult Ty = Actions.ActOnTypeName(getCurScope(), DeclaratorInfo); - if (Ty.isInvalid()) { - SkipUntil(tok::r_brace, /*StopAtSemi=*/true, /*DontConsume=*/true); - if (Tok.is(tok::semi)) - ConsumeToken(); - return StmtError(); - } - - ExprResult MsgExpr = ParseObjCMessageExpressionBody(SourceLocation(), - SourceLocation(), - Ty.get(), 0); - return ParseExprStatement(attrs, MsgExpr); - } - - // Objective-C supports syntax of the form 'id<proto1,proto2>' where - // 'id' is a specific typedef and 'itf<proto1,proto2>' where 'itf' is - // an Objective-C interface. - if (Tok.is(tok::less) && getLang().ObjC1) - ParseObjCProtocolQualifiers(DS); - - SourceLocation DeclStart = NameLoc, DeclEnd; - DeclGroupPtrTy Decl = ParseSimpleDeclaration(DS, Stmts, - Declarator::BlockContext, - DeclEnd, true); - return Actions.ActOnDeclStmt(Decl, DeclStart, DeclEnd); - } - - // In C++, we might also have a functional-style cast. Just annotate - // this as a type token. + case Sema::NC_Type: Tok.setKind(tok::annot_typename); setTypeAnnotation(Tok, Classification.getType()); Tok.setAnnotationEndLoc(NameLoc); Tok.setLocation(NameLoc); PP.AnnotateCachedTokens(Tok); break; - } case Sema::NC_Expression: ConsumeToken(); // the identifier |