This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Don't handle #pragma in cp_lexer_peek_token
- From: Zack Weinberg <zack at codesourcery dot com>
- To: Stan Shebs <shebs at apple dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 21 Sep 2004 15:32:21 -0700
- Subject: Re: Don't handle #pragma in cp_lexer_peek_token
- References: <87isa71haz.fsf@codesourcery.com> <4150A881.2000507@apple.com>
Stan Shebs <shebs@apple.com> writes:
> Zack Weinberg wrote:
>
>>It is silly to check for CPP_PRAGMA tokens every single time we get a
>>new token. In practice, #pragma can appear in only two places: at top
>>level, or inside a compound statement. Accordingly, this patch moves
>>the check for #pragma to cp_parser_declaration_seq_opt and
>>cp_parser_statement. I did not put the check in cp_parser_declaration
>>because we do *not* want to allow something like this:
>>
>>int foo(int x,
>>#pragma wibble
>> int y);
>>
> So, uh, what happens to existing source code written this way?
> New and unexpected kinds of syntax errors?
Yeah, pretty much.
test.c:1: error: expected identifier before 'PRAGMA' token
test.c:1: error: expected `,' or `...' before 'PRAGMA' token
test.c:3: error: ISO C++ forbids declaration of `parameter' with no type
I am not concerned; given what the existing #pragmas do, and given
what the #pragmas we are likely to add do (the STDC set and the OpenMP
set) I don't think anyone has got such code.
zw