public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Joseph Myers <josmyers@redhat.com>
To: Andi Kleen <ak@linux.intel.com>
Cc: gcc-patches@gnu.org
Subject: Re: [PATCH v2 3/5] C: Implement musttail attribute for returns
Date: Fri, 26 Jan 2024 09:35:57 +0000 (UTC)	[thread overview]
Message-ID: <d5a16d35-e0e0-491-7686-926955aafc85@redhat.com> (raw)
In-Reply-To: <ZbN3njHOEMmS8BZW@tassilo>

On Fri, 26 Jan 2024, Andi Kleen wrote:

> > > I don't have tests for that but since it's not new behavior I suppose
> > > that's sufficient.
> > 
> > Each attribute should have tests that invalid uses are appropriately 
> > diagnosed.  See gcc.dg/c23-attr-fallthrough-2.c for examples of such tests 
> > in the case of the [[fallthrough]] attribute.  Some invalid uses may be 
> > diagnosed by existing code that's generic across attributes, others 
> > require specific code for the individual attribute.
> 
> Okay I can add a test for the other statement and declaration cases like
> below.
> 
> Any other change you need for approval?

I use testcases as a key part of the review of a patch, to see if the 
behavior is as I'd expect, so will need to see the updated patch series.

As we're in regression-fixing mode for GCC 14, a new feature like this 
will need to wait for consideration until after GCC 14 branches.

> > The default parsing of an attribute without an entry in the table of 
> > attribute handlers is that arbitrary balanced token sequences are parsed 
> > and discarded as arguments.
> 
> And it triggers a warning too (see below)

For attribute arguments, the key test is [[gnu::musttail()]] on a return 
statement where the attribute would be valid were it not for the attribute 
arguments.

> BTW I noticed that [[musttail]] ; (empty statement with attribute) gives an error, which
> is probably a (unrelated) bug, afaik that should be legal for C23.

That's defined in the standard as an attribute declaration, not an 
attribute on a statement (empty statements can't have attributes).  The 
only currently supported attribute valid in an attribute declaration is 
[[fallthrough]].

When you give an attribute in C23 syntax without a namespace (so 
[[musttail]] as opposed to [[gnu::musttail]]), if it's not a known 
standard attribute then it fails the constraint in 6.7.12.1p2, "The 
identifier in a standard attribute shall be one of: [list]".

-- 
Joseph S. Myers
josmyers@redhat.com


  reply	other threads:[~2024-01-26  9:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-24 19:30 Andi Kleen
2024-01-24 19:30 ` [PATCH v2 1/5] Improve must tail in RTL backend Andi Kleen
2024-01-24 19:30 ` [PATCH v2 2/5] C++: Support clang compatible [[musttail]] (PR83324) Andi Kleen
2024-01-24 19:30 ` [PATCH v2 3/5] C: Implement musttail attribute for returns Andi Kleen
2024-01-25 20:08   ` Joseph Myers
2024-01-25 20:39     ` Andi Kleen
2024-01-26  8:48       ` Joseph Myers
2024-01-26  9:13         ` Andi Kleen
2024-01-26  9:35           ` Joseph Myers [this message]
2024-01-24 19:30 ` [PATCH v2 4/5] Add tests for C/C++ musttail attributes Andi Kleen
2024-01-24 19:30 ` [PATCH v2 5/5] Add documentation for musttail attribute Andi Kleen
2024-01-25  6:51   ` rep.dot.nop
2024-01-25  8:48     ` Andi Kleen

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=d5a16d35-e0e0-491-7686-926955aafc85@redhat.com \
    --to=josmyers@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=gcc-patches@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).