[cfe-dev] Weird behavior while parsing nested (and non) pragmas

Simone Pellegrini spellegrini at dps.uibk.ac.at
Wed Aug 25 12:26:09 PDT 2010


On 08/25/2010 07:59 PM, Sebastian Redl wrote:
> On Aug 25, 2010, at 8:47 AM, Simone Pellegrini wrote:
>
>    
>> I have to say,
>> to be complete, that in order to parse the pragmas I manually call the
>> ConsumeToken() of the Parser class, could be this the problem?
>>      
> Yes. ConsumeToken returns the SourceLocation of the token just consumed. Now, ParseCompoundStatement asserts that the current token is an opening brace and then calls ParseCompoundStatementBody. PCSB doesn't contain an assert. It simply assumes that the first token is the opening brace and consumes it, storing the returned source location, which is then passed to ActOnCompoundStatement as the location of the lbrace.
>
>    
I see.
> Now, if you do your own thing there, consume the lbrace, and leave some other random token in the stream for PCSB to consume, obviously the source location you get would be that of that random thing.
>    
Ok, I understand, but how can I insert a token in the token stream?

thanks for the help, Simone
> Sebastian




More information about the cfe-dev mailing list