Commit 49b91f05 by Nicola Pero Committed by Nicola Pero

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
parent 10ad386a
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.
2010-09-30 Tom G. Christensen <tgc@jupiterrise.com> 2010-09-30 Tom G. Christensen <tgc@jupiterrise.com>
* doc/install.texi (Binaries): Update link to HP-UX porting centre. * doc/install.texi (Binaries): Update link to HP-UX porting centre.
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.
2010-09-29 Nicola Pero <nicola.pero@meta-innovation.com> 2010-09-29 Nicola Pero <nicola.pero@meta-innovation.com>
Merge from 'apple/trunk' branch on FSF servers. Merge from 'apple/trunk' branch on FSF servers.
......
...@@ -370,6 +370,12 @@ c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags, ...@@ -370,6 +370,12 @@ c_lex_with_flags (tree *value, location_t *loc, unsigned char *cpp_flags,
|| OBJC_IS_CXX_KEYWORD (C_RID_CODE (*value))) || OBJC_IS_CXX_KEYWORD (C_RID_CODE (*value)))
{ {
type = CPP_AT_NAME; type = CPP_AT_NAME;
/* Note the complication: if we found an OBJC_CXX
keyword, for example, 'class', we will be
returning a token of type CPP_AT_NAME and rid
code RID_CLASS (not RID_AT_CLASS). The language
parser needs to convert that to RID_AT_CLASS.
*/
break; break;
} }
/* FALLTHROUGH */ /* FALLTHROUGH */
......
...@@ -310,7 +310,25 @@ c_lex_one_token (c_parser *parser, c_token *token) ...@@ -310,7 +310,25 @@ c_lex_one_token (c_parser *parser, c_token *token)
case CPP_AT_NAME: case CPP_AT_NAME:
/* This only happens in Objective-C; it must be a keyword. */ /* This only happens in Objective-C; it must be a keyword. */
token->type = CPP_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; break;
case CPP_COLON: case CPP_COLON:
case CPP_COMMA: case CPP_COMMA:
...@@ -1106,7 +1124,7 @@ c_parser_external_declaration (c_parser *parser) ...@@ -1106,7 +1124,7 @@ c_parser_external_declaration (c_parser *parser)
gcc_assert (c_dialect_objc ()); gcc_assert (c_dialect_objc ());
c_parser_objc_class_definition (parser, NULL_TREE); c_parser_objc_class_definition (parser, NULL_TREE);
break; break;
case RID_CLASS: case RID_AT_CLASS:
gcc_assert (c_dialect_objc ()); gcc_assert (c_dialect_objc ());
c_parser_objc_class_declaration (parser); c_parser_objc_class_declaration (parser);
break; break;
...@@ -4081,7 +4099,7 @@ c_parser_statement_after_labels (c_parser *parser) ...@@ -4081,7 +4099,7 @@ c_parser_statement_after_labels (c_parser *parser)
case RID_ASM: case RID_ASM:
stmt = c_parser_asm_statement (parser); stmt = c_parser_asm_statement (parser);
break; break;
case RID_THROW: case RID_AT_THROW:
gcc_assert (c_dialect_objc ()); gcc_assert (c_dialect_objc ());
c_parser_consume_token (parser); c_parser_consume_token (parser);
if (c_parser_next_token_is (parser, CPP_SEMICOLON)) if (c_parser_next_token_is (parser, CPP_SEMICOLON))
...@@ -4097,7 +4115,7 @@ c_parser_statement_after_labels (c_parser *parser) ...@@ -4097,7 +4115,7 @@ c_parser_statement_after_labels (c_parser *parser)
goto expect_semicolon; goto expect_semicolon;
} }
break; break;
case RID_TRY: case RID_AT_TRY:
gcc_assert (c_dialect_objc ()); gcc_assert (c_dialect_objc ());
c_parser_objc_try_catch_statement (parser); c_parser_objc_try_catch_statement (parser);
break; break;
...@@ -6483,19 +6501,19 @@ c_parser_objc_class_instance_variables (c_parser *parser) ...@@ -6483,19 +6501,19 @@ c_parser_objc_class_instance_variables (c_parser *parser)
break; break;
} }
/* Parse any objc-visibility-spec. */ /* 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); c_parser_consume_token (parser);
objc_set_visibility (2); objc_set_visibility (2);
continue; 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); c_parser_consume_token (parser);
objc_set_visibility (0); objc_set_visibility (0);
continue; 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); c_parser_consume_token (parser);
objc_set_visibility (1); objc_set_visibility (1);
...@@ -6530,7 +6548,7 @@ static void ...@@ -6530,7 +6548,7 @@ static void
c_parser_objc_class_declaration (c_parser *parser) c_parser_objc_class_declaration (c_parser *parser)
{ {
tree list = NULL_TREE; 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); c_parser_consume_token (parser);
/* Any identifiers, including those declared as type names, are OK /* Any identifiers, including those declared as type names, are OK
here. */ here. */
...@@ -7052,12 +7070,12 @@ c_parser_objc_try_catch_statement (c_parser *parser) ...@@ -7052,12 +7070,12 @@ c_parser_objc_try_catch_statement (c_parser *parser)
{ {
location_t loc; location_t loc;
tree stmt; 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); c_parser_consume_token (parser);
loc = c_parser_peek_token (parser)->location; loc = c_parser_peek_token (parser)->location;
stmt = c_parser_compound_statement (parser); stmt = c_parser_compound_statement (parser);
objc_begin_try_stmt (loc, stmt); 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; struct c_parm *parm;
c_parser_consume_token (parser); c_parser_consume_token (parser);
......
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.
2010-09-29 Richard Guenther <rguenther@suse.de> 2010-09-29 Richard Guenther <rguenther@suse.de>
* cp-tree.h (CP_DECL_CONTEXT): Check DECL_FILE_SCOPE_P. * cp-tree.h (CP_DECL_CONTEXT): Check DECL_FILE_SCOPE_P.
......
...@@ -565,21 +565,28 @@ cp_lexer_get_preprocessor_token (cp_lexer *lexer, cp_token *token) ...@@ -565,21 +565,28 @@ cp_lexer_get_preprocessor_token (cp_lexer *lexer, cp_token *token)
token->keyword = RID_MAX; token->keyword = RID_MAX;
} }
} }
/* Handle Objective-C++ keywords. */
else if (token->type == CPP_AT_NAME) else if (token->type == CPP_AT_NAME)
{ {
/* This only happens in Objective-C++; it must be a keyword. */
token->type = CPP_KEYWORD; token->type = CPP_KEYWORD;
switch (C_RID_CODE (token->u.value)) switch (C_RID_CODE (token->u.value))
{ {
/* Map 'class' to '@class', 'private' to '@private', etc. */ /* Replace 'class' with '@class', 'private' with '@private',
case RID_CLASS: token->keyword = RID_AT_CLASS; break; etc. This prevents confusion with the C++ keyword
case RID_PRIVATE: token->keyword = RID_AT_PRIVATE; break; '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_PROTECTED: token->keyword = RID_AT_PROTECTED; break;
case RID_PUBLIC: token->keyword = RID_AT_PUBLIC; break; case RID_PUBLIC: token->keyword = RID_AT_PUBLIC; break;
case RID_THROW: token->keyword = RID_AT_THROW; break; case RID_THROW: token->keyword = RID_AT_THROW; break;
case RID_TRY: token->keyword = RID_AT_TRY; break; case RID_TRY: token->keyword = RID_AT_TRY; break;
case RID_CATCH: token->keyword = RID_AT_CATCH; break; case RID_CATCH: token->keyword = RID_AT_CATCH; break;
default: token->keyword = C_RID_CODE (token->u.value); default: token->keyword = C_RID_CODE (token->u.value);
} }
} }
else if (token->type == CPP_PRAGMA) else if (token->type == CPP_PRAGMA)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment