[Bug c/55681] New: Qualifiers on asm statements are order-dependent

josh.m.conner at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri Dec 14 02:30:00 GMT 2012


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55681

             Bug #: 55681
           Summary: Qualifiers on asm statements are order-dependent
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: josh.m.conner@gmail.com


The syntax that is accepted for asm statement qualifiers is:

  asm {volatile | const | restrict} {goto}

(this can easily be seen by looking at the code in c_parser_asm_statement).

This means, for example, that gcc isn't particularly orthogonal in what it
chooses to accept and reject:

  asm volatile ("nop");                      // accepted
  asm const ("nop");                         // accepted with warning
  asm __restrict ("nop");                    // accepted with warning
  asm const volatile ("nop");                // parse error
  asm const __restrict ("nop");              // parse error
  asm volatile goto ("nop" : : : : label);   // accepted
  asm goto volatile ("nop" : : : : label);   // parse error

This is probably rarely a problem, since most of the statements that would
result in an error are not likely to be seen (I came across this when adding a
new qualifier for our local port, which exacerbated the problem), but I thought
I would mention it anyway -- the fix is relatively straightforward since the
qualifiers are independent.



More information about the Gcc-bugs mailing list