public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* [Bug] Attributes cannot be applied to asm statements
@ 2023-07-19  7:13 Julian Waters
  2023-07-19  7:41 ` Jonathan Wakely
  0 siblings, 1 reply; 4+ messages in thread
From: Julian Waters @ 2023-07-19  7:13 UTC (permalink / raw)
  To: gcc-help

[-- Attachment #1: Type: text/plain, Size: 1103 bytes --]

Sorry for posting this here, I am unable to create an issue in the gcc
tracker

Consider the following:

[[gnu::no_reorder]]
asm ("nop");

The correct gcc warning should be that "attributes in front of statements
are ignored", signifying that the asm was correctly processed as a
statement, and the attribute dropped during that processing, but instead:

error.cpp:51:5: error: expected primary-expression before 'asm'
   51 |     asm ("nop" "\n\t"
      |     ^~~
error.cpp:50:5: warning: attributes at the beginning of statement are
ignored [-Wattributes]
   50 |     [[gnu::no_reorder]]
      |     ^~~~~~~~~~~~~~~~~~~

The compiler errors out, with the parser strangely having expected an
expression after the attribute. Afterwards, it then confusingly parses the
asm statement and discards the attribute correctly, so I am fairly certain
this is a bug. The attribute above may not be a very good example, but
there are attributes like gnu::hot and gnu::cold which are supposed to work
with asm statements. Could someone help me post this to the bug tracker?
Thanks in advance

best regards,
Julian

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-07-19  7:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-19  7:13 [Bug] Attributes cannot be applied to asm statements Julian Waters
2023-07-19  7:41 ` Jonathan Wakely
2023-07-19  7:44   ` Julian Waters
2023-07-19  7:47     ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).