[cfe-commits] r161703 - in /cfe/trunk: include/clang/AST/Stmt.h lib/AST/Stmt.cpp

Richard Smith richard at metafoo.co.uk
Tue Aug 14 13:14:30 PDT 2012


On Tue, Aug 14, 2012 at 11:56 AM, Abramo Bagnara
<abramo.bagnara at gmail.com>wrote:

> Il 14/08/2012 20:19, Richard Smith ha scritto:
> >
> > On 13 Aug 2012 23:12, "Abramo Bagnara" <abramo.bagnara at gmail.com
> > <mailto:abramo.bagnara at gmail.com>> wrote:
> >>
> >> Il 13/08/2012 23:54, Eli Friedman ha scritto:
> >> > On Mon, Aug 13, 2012 at 2:01 PM, Richard Smith
> > <richard at metafoo.co.uk <mailto:richard at metafoo.co.uk>> wrote:
> >> >> According to the documentation I can find[1], multiple __asm
> > constructs are
> >> >> separate statements. In particular, the documentation suggests that
> > here:
> >> >>
> >> >> void f() {
> >> >>   if (false)
> >> >>     __asm mov eax, ebx
> >> >>   __asm mov ebx, eax
> >> >> }
> >> >>
> >> >> the second __asm statement is not controlled by the 'if'. If the
> >> >> documentation is correct, we currently misparse this.
> >> >>
> >> >> [1] http://msdn.microsoft.com/en-us/library/45yd4tzz(v=vs.110).aspx
> >> >
> >> > I think clang's interpretation is actually right here, but someone
> >> > should actually try that on MSVC.
> >>
> >> void f(int x) {
> >>         if (x)
> >>                 __asm out dx, ax
> >>         __asm out dx, ax
> >
> > What about these:
> >
> >     if (x)
> >        __asm out dx, ax  __asm out dx, ax
> >     if (x)
> >        __asm out dx, ax ; __asm out dx, ax
> >     if (x)
> >         __asm out dx, ax ; out dx, ax
> >
> > To my reading, the first two are two statements and the third is one
> > statement.
>
> Unfortunately not: in the first there is one statement formed by two
> "out dx, ax", in the second and the third the text after semicolon is
> ignored.
>
> So I'd say that the rules outside {} are:
>
> 1) a semicolon in the same line of an __asm is assumed to begin a
> comment ending at end of line
> 2) a newline ends an asm statement
> 3) an __asm begins a new asm instruction
>
> Inside {} are:
>
> 1) a semicolon is assumed to begin a comment ending at end of line (this
> means it can eat also a '}')
> 2) a newline ends an asm instruction
> 3) an __asm begins a new asm instruction
>

Aha, there's another documentation page which somewhat contradicts the
first, but seems more accurate:

http://msdn.microsoft.com/en-us/library/352sth8z(v=vs.80).aspx

One final question, what does MSVC make of this:

  __asm out dx, ax ; this comment isn't tokenizable

If it accepts it, we may have to handle __asm in the lexer.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120814/3ccb4579/attachment.html>


More information about the cfe-commits mailing list