diff options
author | Nicola Pero <nicola.pero@meta-innovation.com> | 2010-09-29 07:34:37 +0000 |
---|---|---|
committer | Nicola Pero <nicola@gcc.gnu.org> | 2010-09-29 07:34:37 +0000 |
commit | 1973201f322176cdcc551f7ab968c4e5cd66cd83 (patch) | |
tree | 50e01956f9f732acde8196766d84e5b5013a2ea6 /gcc/c-parser.c | |
parent | 3f984eefb1a566600f545f0d0c7289d6c3d7657a (diff) | |
download | gcc-1973201f322176cdcc551f7ab968c4e5cd66cd83.zip gcc-1973201f322176cdcc551f7ab968c4e5cd66cd83.tar.gz gcc-1973201f322176cdcc551f7ab968c4e5cd66cd83.tar.bz2 |
In gcc/: 2010-09-29 Nicola Pero <nicola.pero@meta-innovation.com>
In gcc/:
2010-09-29 Nicola Pero <nicola.pero@meta-innovation.com>
* c-parser.c (c_lex_one_token): In Objective-C, when dealing with
a CPP_NAME which is a reserved word, clearly separate cases for
OBJC_IS_PQ_KEYWORD, OBJC_IS_AT_KEYWORD and OBJC_IS_CXX_KEYWORD.
In gcc/c-family:
2010-09-29 Nicola Pero <nicola.pero@meta-innovation.com>
* c-common.h (OBJC_IS_CXX_KEYWORD): New macro. Updated comments.
(objc_is_reserved_word): Removed.
* c-common.c: Updated comments.
* c-lex.c (c_lex_with_flags): Use OBJC_IS_CXX_KEYWORD instead of
objc_is_reserved_word.
* stub-objc.c (objc_is_reserved_word): Removed.
In gcc/objc/:
2010-09-29 Nicola Pero <nicola.pero@meta-innovation.com>
* objc-act.c (objc_is_reserved_word): Removed.
In gcc/testsuite/:
2010-09-29 Nicola Pero <nicola.pero@meta-innovation.com>
* objc.dg/keywords-1.m: New test.
* objc.dg/keywords-2.m: New test.
* objc.dg/keywords-3.m: New test.
* obj-c++.dg/keywords-1.mm: New test.
* obj-c++.dg/keywords-2.mm: New test.
From-SVN: r164715
Diffstat (limited to 'gcc/c-parser.c')
-rw-r--r-- | gcc/c-parser.c | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/gcc/c-parser.c b/gcc/c-parser.c index 2ad1658..d21cd76 100644 --- a/gcc/c-parser.c +++ b/gcc/c-parser.c @@ -179,7 +179,11 @@ typedef struct GTY(()) c_parser { BOOL_BITFIELD in_if_block : 1; /* True if we want to lex an untranslated string. */ BOOL_BITFIELD lex_untranslated_string : 1; + /* Objective-C specific parser/lexer information. */ + + /* True if we are in a context where the Objective-C "PQ" keywords + are considered keywords. */ BOOL_BITFIELD objc_pq_context : 1; /* The following flag is needed to contextualize Objective-C lexical analysis. In some cases (e.g., 'int NSObject;'), it is @@ -236,16 +240,37 @@ c_lex_one_token (c_parser *parser, c_token *token) token->keyword = rid_code; break; } - else if (c_dialect_objc ()) + else if (c_dialect_objc () && OBJC_IS_PQ_KEYWORD (rid_code)) { - if (!objc_is_reserved_word (token->value) - && (!OBJC_IS_PQ_KEYWORD (rid_code) - || parser->objc_pq_context)) + /* We found an Objective-C "pq" keyword (in, out, + inout, bycopy, byref, oneway). They need special + care because the interpretation depends on the + context. + */ + if (parser->objc_pq_context) { token->type = CPP_KEYWORD; token->keyword = rid_code; break; } + /* Else, "pq" keywords outside of the "pq" context are + not keywords, and we fall through to the code for + normal tokens. + */ + } + else if (c_dialect_objc () + && (OBJC_IS_AT_KEYWORD (rid_code) + || OBJC_IS_CXX_KEYWORD (rid_code))) + { + /* We found one of the Objective-C "@" keywords (defs, + selector, synchronized, etc) or one of the + Objective-C "cxx" keywords (class, private, + protected, public, try, catch, throw) without a + preceding '@' sign. Do nothing and fall through to + the code for normal tokens (in C++ we would still + consider the CXX ones keywords, but not in C). + */ + ; } else { |