public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Julian Waters <tanksherman27@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: [Bug] Attributes cannot be applied to asm statements
Date: Wed, 19 Jul 2023 15:13:37 +0800	[thread overview]
Message-ID: <CAP2b4GPhnO_CShQYaa1b6BWJ1cmxsxLdm=Tj2ECE8P9YDrd1qA@mail.gmail.com> (raw)

[-- 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

             reply	other threads:[~2023-07-19  7:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-19  7:13 Julian Waters [this message]
2023-07-19  7:41 ` Jonathan Wakely
2023-07-19  7:44   ` Julian Waters
2023-07-19  7:47     ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAP2b4GPhnO_CShQYaa1b6BWJ1cmxsxLdm=Tj2ECE8P9YDrd1qA@mail.gmail.com' \
    --to=tanksherman27@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).