From: Douglas Gregor Date: Mon, 1 Dec 2008 21:46:47 +0000 (+0000) Subject: Objective-C keywords are not always identifiers. Some are also C++ keywords X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bec1c9d6f3feeec112cc8eeae90c1be29c6aaf13;p=clang Objective-C keywords are not always identifiers. Some are also C++ keywords git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@60373 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp index d72c319d97..f85cfd9f0f 100644 --- a/lib/Lex/Lexer.cpp +++ b/lib/Lex/Lexer.cpp @@ -41,8 +41,9 @@ static void InitCharacterInfo(); /// isObjCAtKeyword - Return true if we have an ObjC keyword identifier. bool Token::isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const { - return is(tok::identifier) && - getIdentifierInfo()->getObjCKeywordID() == objcKey; + if (IdentifierInfo *II = getIdentifierInfo()) + return II->getObjCKeywordID() == objcKey; + return false; } /// getObjCKeywordID - Return the ObjC keyword kind. diff --git a/test/Parser/objc-try-catch-1.m b/test/Parser/objc-try-catch-1.m index 072c4609eb..d8264fabbe 100644 --- a/test/Parser/objc-try-catch-1.m +++ b/test/Parser/objc-try-catch-1.m @@ -1,5 +1,5 @@ -// RUN: clang -fsyntax-only -verify %s - +// RUN: clang -fsyntax-only -verify %s && +// RUN: clang -fsyntax-only -verify -x objective-c++ %s void * proc(); @interface NSConstantString