[patch] new exec-charset testcase

Zack Weinberg zack@codesourcery.com
Tue Apr 20 05:50:00 GMT 2004


Mark Mitchell <mark@codesourcery.com> writes:

> I thought the deal here was that most string constants were
> translated, but things like 'extern "C"' were not.  And that the
> contents of __asm__ s were not.
>  You could conceivably teach the lexer about these constructs; they're
> not *that* complicated.

Yes, but the things that can contain such constructs, and that get
tentatively parsed, are quite messy indeed.  The test case in Eric's
message that I originally replied to, cc:ing you, was

int main()
{
  unsigned long int *ptr;
  ptr = ((unsigned long int *)
         ( { void *stack_ptr;
           __asm__ __volatile__ ( "foo %0" : "=r" (stack_ptr) );
           (stack_ptr); } ) );
  return 0;
}

(Yeah, you are probably going to say something nasty about statement
expressions, and I might even agree with you.)

>>I'll take your word on it though and plan on redoing the tree for the
>>string node when I encounter a place to translate and turning off the
>>translation stuff in the lexer for this.
>>
> That's going to be the better way to go.  In practice, you're not
> going to be generating excess string constants very often; that will
> only happen when the initial parse would not result in translation but
> the actual parse will, or vice versa.  (A meta-note is that we could
> probably do somewhat less tentative parsing that we do, and that might
> be a performance win in other ways.)

How's this sound?  Invent a C++-specific tree flag that means 'this
STRING_CST has not been translated yet (whether or not it should be).'
Always produce such STRING_CSTs when parsing tentatively.  Then when
we go back and parse definitely, you can convert them.

... Oh, bother, you're going to run smack into the mess where the
standard requires string constant concatenation, escape sequence
interpretation, and conversion to the execution character set, all to
occur at once.  Perhaps it would be feasible to get round this by
using TREE_VECs of STRING_CSTs in the case where you have to delay
string constant concatenation (which will be rarely).

zw



More information about the Gcc-patches mailing list