aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-parser.c
diff options
context:
space:
mode:
authorNicola Pero <nicola.pero@meta-innovation.com>2010-09-30 08:23:37 +0000
committerNicola Pero <nicola@gcc.gnu.org>2010-09-30 08:23:37 +0000
commit49b91f055dbcf33c0230356a6ff41916c7cac917 (patch)
treefebeddb29ba321d8891cab7a7b66a19df3e27ea9 /gcc/c-parser.c
parent10ad386ac38c8c9de3e7eb4fcdfaf597c8e1d591 (diff)
downloadgcc-49b91f055dbcf33c0230356a6ff41916c7cac917.zip
gcc-49b91f055dbcf33c0230356a6ff41916c7cac917.tar.gz
gcc-49b91f055dbcf33c0230356a6ff41916c7cac917.tar.bz2
In gcc/c-family/: 2010-09-30 Nicola Pero <nicola.pero@meta-innovation.com>
In gcc/c-family/: 2010-09-30 Nicola Pero <nicola.pero@meta-innovation.com> * c-lex.c (c_lex_with_flags): Updated comments for CPP_AT_NAME Objective-C/Objective-C++ keywords. In gcc/cp/: 2010-09-30 Nicola Pero <nicola.pero@meta-innovation.com> * parser.c (cp_lexer_get_preprocessor_token): Tidied up comments and indentation when finding an Objective-C++ CPP_AT_NAME token. In gcc/: 2010-09-30 Nicola Pero <nicola.pero@meta-innovation.com> * c-parser.c (c_lex_one_token): When finding a CPP_AT_NAME Objective-C token, map RID_CLASS to RID_AT_CLASS and similar. (c_parser_external_declaration): Use RID_AT_CLASS instead of RID_CLASS. (c_parser_objc_class_declaration): Same change. (c_parser_objc_try_catch_statement): Use RID_AT_TRY instead of RID_TRY and RID_AT_CATCH instead of RID_CATCH. (c_parser_objc_class_instance_variables): Use RID_AT_PRIVATE instead of RID_PRIVATE, RID_AT_PROTECTED instead of RID_PROTECTED and RID_AT_PUBLIC instead of RID_PUBLIC. (c_parser_statement_after_labels): Use RID_AT_TRY instead of RID_TRY and RID_AT_CATCH instead of RID_CATCH. From-SVN: r164744
Diffstat (limited to 'gcc/c-parser.c')
-rw-r--r--gcc/c-parser.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/gcc/c-parser.c b/gcc/c-parser.c
index cf61b93..5640774 100644
--- a/gcc/c-parser.c
+++ b/gcc/c-parser.c
@@ -310,7 +310,25 @@ c_lex_one_token (c_parser *parser, c_token *token)
case CPP_AT_NAME:
/* This only happens in Objective-C; it must be a keyword. */
token->type = CPP_KEYWORD;
- token->keyword = C_RID_CODE (token->value);
+ switch (C_RID_CODE (token->value))
+ {
+ /* 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->value);
+ }
break;
case CPP_COLON:
case CPP_COMMA:
@@ -1106,7 +1124,7 @@ c_parser_external_declaration (c_parser *parser)
gcc_assert (c_dialect_objc ());
c_parser_objc_class_definition (parser, NULL_TREE);
break;
- case RID_CLASS:
+ case RID_AT_CLASS:
gcc_assert (c_dialect_objc ());
c_parser_objc_class_declaration (parser);
break;
@@ -4081,7 +4099,7 @@ c_parser_statement_after_labels (c_parser *parser)
case RID_ASM:
stmt = c_parser_asm_statement (parser);
break;
- case RID_THROW:
+ case RID_AT_THROW:
gcc_assert (c_dialect_objc ());
c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_SEMICOLON))
@@ -4097,7 +4115,7 @@ c_parser_statement_after_labels (c_parser *parser)
goto expect_semicolon;
}
break;
- case RID_TRY:
+ case RID_AT_TRY:
gcc_assert (c_dialect_objc ());
c_parser_objc_try_catch_statement (parser);
break;
@@ -6483,19 +6501,19 @@ c_parser_objc_class_instance_variables (c_parser *parser)
break;
}
/* Parse any objc-visibility-spec. */
- if (c_parser_next_token_is_keyword (parser, RID_PRIVATE))
+ if (c_parser_next_token_is_keyword (parser, RID_AT_PRIVATE))
{
c_parser_consume_token (parser);
objc_set_visibility (2);
continue;
}
- else if (c_parser_next_token_is_keyword (parser, RID_PROTECTED))
+ else if (c_parser_next_token_is_keyword (parser, RID_AT_PROTECTED))
{
c_parser_consume_token (parser);
objc_set_visibility (0);
continue;
}
- else if (c_parser_next_token_is_keyword (parser, RID_PUBLIC))
+ else if (c_parser_next_token_is_keyword (parser, RID_AT_PUBLIC))
{
c_parser_consume_token (parser);
objc_set_visibility (1);
@@ -6530,7 +6548,7 @@ static void
c_parser_objc_class_declaration (c_parser *parser)
{
tree list = NULL_TREE;
- gcc_assert (c_parser_next_token_is_keyword (parser, RID_CLASS));
+ gcc_assert (c_parser_next_token_is_keyword (parser, RID_AT_CLASS));
c_parser_consume_token (parser);
/* Any identifiers, including those declared as type names, are OK
here. */
@@ -7052,12 +7070,12 @@ c_parser_objc_try_catch_statement (c_parser *parser)
{
location_t loc;
tree stmt;
- gcc_assert (c_parser_next_token_is_keyword (parser, RID_TRY));
+ gcc_assert (c_parser_next_token_is_keyword (parser, RID_AT_TRY));
c_parser_consume_token (parser);
loc = c_parser_peek_token (parser)->location;
stmt = c_parser_compound_statement (parser);
objc_begin_try_stmt (loc, stmt);
- while (c_parser_next_token_is_keyword (parser, RID_CATCH))
+ while (c_parser_next_token_is_keyword (parser, RID_AT_CATCH))
{
struct c_parm *parm;
c_parser_consume_token (parser);