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 josmy...@redhat.com