On Thu, 25 Jan 2024, Andi Kleen wrote: > On Thu, Jan 25, 2024 at 08:08:23PM +0000, Joseph Myers wrote: > > On Wed, 24 Jan 2024, Andi Kleen wrote: > > > > > Implement a C23 clang compatible musttail attribute similar to the earlier > > > C++ implementation in the C parser. > > > > I'd expect diagnostics, and associated tests of those diagnostics, for: > > > > * musttail attribute used with any arguments, even empty > > [[gnu::musttail()]], much like e.g. [[fallthrough()]] or > > [[maybe_unused()]] gets diagnosed. > > These happen naturally because the attribute doesn't get removed when > not in front of return, and it gets warned about like any other unknown > attribute: > > tattr.c:5:9: warning: ‘musttail’ attribute ignored [-Wattributes] > 5 | [[gnu::musttail]] i++; > | ^ > > 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. 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. To diagnose such arguments (in contexts when the attribute is otherwise valid), an entry in the table of attribute handlers is appropriate. -- Joseph S. Myers josmy...@redhat.com