[patch] new exec-charset testcase
Mark Mitchell
mark@codesourcery.com
Wed Apr 21 03:39:00 GMT 2004
Eric Christopher wrote:
>>You did see where I said "or another opening parenthesis" anticipating
>>this issue, didn't you? :-) If the counter is exactly one translate --
>>otherwise don't.
>>
>>
>>
>
>Hmm... *thinks about things* I don't think that'll work for this
>testcase given how the cast parsing mechanism works - or will it?
>
>int main()
>{
> unsigned long int *ptr;
> ptr = ((unsigned long int *)
> ( { void *stack_ptr;
> __asm__ __volatile__ ( "foo %0" : "=r" (stack_ptr) );
> (stack_ptr); } ) );
> return 0;
>}
>
>
I think it would work. What I'm proposing is entirely in the lexer; it
would be a little tiny bit of parsing in the lexer. (Basically, a
counter keeping track of the number of open parentheses seen since the
last __asm__. And similar stuf for attributes, etc.)
I'm not necessarily saying this is the best plan. It's probably more
complex than saving the original untranslated string and generating new
trees after a tentative parse. But, doing it in the lexer would avoid
creating unneeded trees.
The lexer is the right place to do this stuff, in principle; the parser
should just see a stream of tokens. Unfortunately, you've got a lexical
analysis situation that is context-sensitive; that's often thought to be
a sign of poor design. Not that it's your fault, of course.
You could solve this problem by telling the user to write the asm using
Unicode escapes so that it was still in the right character set,
independent of the execution character set. :-)
--
Mark Mitchell
CodeSourcery, LLC
(916) 791-8304
mark@codesourcery.com
More information about the Gcc-patches
mailing list