gnu2x-attr-syntax-1.m
170 Bytes
-
Handle C2x attributes in Objective-C. · 34b43828
When adding the initial support for C2x attributes, I deferred the unbounded lookahead support required to support such attributes in Objective-C (except for the changes to string literal handling, which were the riskier piece of preparation for such lookahead support). This patch adds that remaining ObjC support. For C, the parser continues to work exactly as it did before. For ObjC, however, when checking for whether '[[' starts attributes, it lexes however many tokens are needed to check for a matching ']]', but in a raw mode that omits all the context-sensitive processing that c_lex_with_flags normally does, so that that processing can be done later when the right context-sensitive flags are set. Those tokens are saved in a separate raw_tokens vector in the parser, and normal c_lex_one_token calls will get tokens from there and perform the remaining processing on them, if any tokens are found there, so all parsing not using the new interfaces gets the same tokens as it did before. (For C, this raw lexing never occurs and the vector of raw tokens is always NULL.) Bootstrapped with no regressions for x86_64-pc-linux-gnu. gcc/c: * c-parser.c (struct c_parser): Add members raw_tokens and raw_tokens_used. (c_lex_one_token): Add argument raw. Handle lexing raw tokens and using previously-lexed raw tokens. (c_parser_peek_nth_token_raw) (c_parser_check_balanced_raw_token_sequence): New functions. (c_parser_nth_token_starts_std_attributes): Use c_parser_check_balanced_raw_token_sequence for Objective-C. gcc/testsuite: * objc.dg/attributes/gnu2x-attr-syntax-1.m: New test. From-SVN: r278827
Joseph Myers committed