diff options
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r-- | gcc/cp/parser.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index b622613..d9cc727 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -565,21 +565,28 @@ cp_lexer_get_preprocessor_token (cp_lexer *lexer, cp_token *token) token->keyword = RID_MAX; } } - /* Handle Objective-C++ keywords. */ else if (token->type == CPP_AT_NAME) { + /* This only happens in Objective-C++; it must be a keyword. */ token->type = CPP_KEYWORD; switch (C_RID_CODE (token->u.value)) { - /* Map 'class' to '@class', 'private' to '@private', etc. */ - case RID_CLASS: token->keyword = RID_AT_CLASS; break; - case RID_PRIVATE: token->keyword = RID_AT_PRIVATE; break; + /* Replace 'class' with '@class', 'private' with '@private', + etc. This prevents confusion with the C++ keyword + 'class', and makes the tokens consistent with other + Objective-C 'AT' keywords. For example '@class' is + reported as RID_AT_CLASS which is consistent with + '@synchronized', which is reported as + RID_AT_SYNCHRONIZED. + */ + case RID_CLASS: token->keyword = RID_AT_CLASS; break; + case RID_PRIVATE: token->keyword = RID_AT_PRIVATE; break; case RID_PROTECTED: token->keyword = RID_AT_PROTECTED; break; - case RID_PUBLIC: token->keyword = RID_AT_PUBLIC; break; - case RID_THROW: token->keyword = RID_AT_THROW; break; - case RID_TRY: token->keyword = RID_AT_TRY; break; - case RID_CATCH: token->keyword = RID_AT_CATCH; break; - default: token->keyword = C_RID_CODE (token->u.value); + case RID_PUBLIC: token->keyword = RID_AT_PUBLIC; break; + case RID_THROW: token->keyword = RID_AT_THROW; break; + case RID_TRY: token->keyword = RID_AT_TRY; break; + case RID_CATCH: token->keyword = RID_AT_CATCH; break; + default: token->keyword = C_RID_CODE (token->u.value); } } else if (token->type == CPP_PRAGMA) |