This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Don't handle #pragma in cp_lexer_peek_token


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]