<div class="gmail_quote">On Tue, Aug 14, 2012 at 11:56 AM, Abramo Bagnara <span dir="ltr"><<a href="mailto:abramo.bagnara@gmail.com" target="_blank">abramo.bagnara@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Il 14/08/2012 20:19, Richard Smith ha scritto:<br>
<div class="im">><br>
> On 13 Aug 2012 23:12, "Abramo Bagnara" <<a href="mailto:abramo.bagnara@gmail.com">abramo.bagnara@gmail.com</a><br>
</div><div class="im">> <mailto:<a href="mailto:abramo.bagnara@gmail.com">abramo.bagnara@gmail.com</a>>> wrote:<br>
>><br>
>> Il 13/08/2012 23:54, Eli Friedman ha scritto:<br>
>> > On Mon, Aug 13, 2012 at 2:01 PM, Richard Smith<br>
</div><div><div class="h5">> <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a> <mailto:<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>>> wrote:<br>
>> >> According to the documentation I can find[1], multiple __asm<br>
> constructs are<br>
>> >> separate statements. In particular, the documentation suggests that<br>
> here:<br>
>> >><br>
>> >> void f() {<br>
>> >>   if (false)<br>
>> >>     __asm mov eax, ebx<br>
>> >>   __asm mov ebx, eax<br>
>> >> }<br>
>> >><br>
>> >> the second __asm statement is not controlled by the 'if'. If the<br>
>> >> documentation is correct, we currently misparse this.<br>
>> >><br>
>> >> [1] <a href="http://msdn.microsoft.com/en-us/library/45yd4tzz(v=vs.110).aspx" target="_blank">http://msdn.microsoft.com/en-us/library/45yd4tzz(v=vs.110).aspx</a><br>
>> ><br>
>> > I think clang's interpretation is actually right here, but someone<br>
>> > should actually try that on MSVC.<br>
>><br>
>> void f(int x) {<br>
>>         if (x)<br>
>>                 __asm out dx, ax<br>
>>         __asm out dx, ax<br>
><br>
> What about these:<br>
><br>
>     if (x)<br>
>        __asm out dx, ax  __asm out dx, ax<br>
>     if (x)<br>
>        __asm out dx, ax ; __asm out dx, ax<br>
>     if (x)<br>
>         __asm out dx, ax ; out dx, ax<br>
><br>
> To my reading, the first two are two statements and the third is one<br>
> statement.<br>
<br>
</div></div>Unfortunately not: in the first there is one statement formed by two<br>
"out dx, ax", in the second and the third the text after semicolon is<br>
ignored.<br>
<br>
So I'd say that the rules outside {} are:<br>
<br>
1) a semicolon in the same line of an __asm is assumed to begin a<br>
comment ending at end of line<br>
2) a newline ends an asm statement<br>
3) an __asm begins a new asm instruction<br>
<br>
Inside {} are:<br>
<br>
1) a semicolon is assumed to begin a comment ending at end of line (this<br>
means it can eat also a '}')<br>
2) a newline ends an asm instruction<br>
3) an __asm begins a new asm instruction<br>
</blockquote></div><div><br></div><div>Aha, there's another documentation page which somewhat contradicts the first, but seems more accurate:</div><div><br></div><a href="http://msdn.microsoft.com/en-us/library/352sth8z(v=vs.80).aspx">http://msdn.microsoft.com/en-us/library/352sth8z(v=vs.80).aspx</a><br>
<div><br></div><div>One final question, what does MSVC make of this:</div><div><br></div><div>  __asm out dx, ax ; this comment isn't tokenizable</div><div><br></div><div>If it accepts it, we may have to handle __asm in the lexer.</div>