diff options
-rw-r--r-- | clang/lib/Lex/Lexer.cpp | 4 | ||||
-rw-r--r-- | clang/test/Modules/Inputs/module.map | 4 | ||||
-rw-r--r-- | clang/test/Modules/Inputs/objcAtKeywordMissingEnd.h | 3 | ||||
-rw-r--r-- | clang/test/Modules/objc-at-keyword.m | 7 |
4 files changed, 18 insertions, 0 deletions
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp index 3d6fe91115a..92942fd09a0 100644 --- a/clang/lib/Lex/Lexer.cpp +++ b/clang/lib/Lex/Lexer.cpp @@ -43,6 +43,8 @@ using namespace clang; /// isObjCAtKeyword - Return true if we have an ObjC keyword identifier. bool Token::isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const { + if (isAnnotation()) + return false; if (IdentifierInfo *II = getIdentifierInfo()) return II->getObjCKeywordID() == objcKey; return false; @@ -50,6 +52,8 @@ bool Token::isObjCAtKeyword(tok::ObjCKeywordKind objcKey) const { /// getObjCKeywordID - Return the ObjC keyword kind. tok::ObjCKeywordKind Token::getObjCKeywordID() const { + if (isAnnotation()) + return tok::objc_not_keyword; IdentifierInfo *specId = getIdentifierInfo(); return specId ? specId->getObjCKeywordID() : tok::objc_not_keyword; } diff --git a/clang/test/Modules/Inputs/module.map b/clang/test/Modules/Inputs/module.map index 7416d7008b8..c0fe6c557f2 100644 --- a/clang/test/Modules/Inputs/module.map +++ b/clang/test/Modules/Inputs/module.map @@ -441,3 +441,7 @@ module DebugNestedB { header "DebugNestedB.h" export * } + +module objcAtKeywordMissingEnd { + header "objcAtKeywordMissingEnd.h" +} diff --git a/clang/test/Modules/Inputs/objcAtKeywordMissingEnd.h b/clang/test/Modules/Inputs/objcAtKeywordMissingEnd.h new file mode 100644 index 00000000000..1196b87eef8 --- /dev/null +++ b/clang/test/Modules/Inputs/objcAtKeywordMissingEnd.h @@ -0,0 +1,3 @@ +@interface MissingEnd // expected-note {{class started here}} + +@ // expected-error {{expected an Objective-C directive after '@'}} expected-error {{missing '@end'}} diff --git a/clang/test/Modules/objc-at-keyword.m b/clang/test/Modules/objc-at-keyword.m new file mode 100644 index 00000000000..0e058a30901 --- /dev/null +++ b/clang/test/Modules/objc-at-keyword.m @@ -0,0 +1,7 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -verify -x objective-c -fmodule-name=objcAtKeywordMissingEnd -emit-module %S/Inputs/module.map +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -x objective-c -fmodule-name=Empty -emit-module %S/Inputs/module.map +// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -verify -I %S/Inputs %s + +@interface X // expected-note {{class started here}} +#pragma clang module import Empty // expected-error {{missing '@end'}} |