<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Feb 5, 2014 at 1:08 PM, Harald van Dijk <span dir="ltr"><<a href="mailto:harald@gigawatt.nl" target="_blank">harald@gigawatt.nl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 05/02/14 00:42, Richard Smith wrote:<br>
> Here's an easy test:<br>
><br>
> #define foo() bar() b<br>
> #define bar()<br>
> a<br>
> foo()<br>
> c<br>
><br>
> This should produce:<br>
><br>
> # 1 "..."<br>
><br>
><br>
> a<br>
>  b<br>
> c<br>
><br>
> ... but currently produces:<br>
><br>
> #1 "..."<br>
><br>
><br>
> a b<br>
><br>
> c<br>
<br>
</div>Thanks Richard, I don't know how I managed to miss that.<br>
<br>
Setting Token::StartOfLine as mentioned gets this right in the lexer.<br>
However, even though the b token in the output has both<br>
Token::StartOfLine and Token::LeadingSpace set,<br>
PrintPPOutputPPCallbacks::HandleFirstTokOnLine uses the column number to<br>
determine whether to print spaces, not the flag. As a result, the output<br>
becomes not<br>
<br>
a<br>
 b<br>
c<br>
<br>
but<br>
<br>
a<br>
b<br>
c<br>
<br>
Given that the lexer behaviour is now right, would it be okay to leave<br>
this as it is, and only add a test to check that b is on a separate<br>
line, like attached? (I used first/second/third instead of a/b/c in an<br>
attempt to get FileCheck to print a better suggestion when the test<br>
fails, but it neither helps nor hurts.)</blockquote><div><br></div><div>I'm not sure whether we have consumers of -E that care about this detail, but I think this is an unrelated bug. Consider:</div><div><br></div><div>
#define foo(x) x y</div><div>foo()</div><div><br></div><div>This also misses the leading space from the output. So:</div><div><br></div><div>1) I think your patch is fine as-is, and</div><div>2) I think we should fix PrintPreprocessedTokens to correctly handle the first token on the line having leading space but being expanded from a token in the first column.</div>
</div></div></div>