https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127779

            Bug ID: 127779
           Summary: Cannot apply __attribute__((unused)) to goto labels
           Product: gcc
           Version: 16.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luca.bacci at outlook dot com
  Target Milestone: ---

Docs for -Wunused-label say [1]:

  > -Wunused-label: warn whenever a label is declared but not used [...].
  >                 To suppress this warning use the unused attribute.

And docs for 'attribute unused' say:

  > unused: this attribute can be attached to a function, variable, structure
field, type declaration, or label.

However applying __attribute__((unused)) to a label results in syntax errors:

int
func (void)
{
__attribute__((unused))
retry:

  return 0;
}

Compiler output is [3]:

  > error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token

References:

 [1]
https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wunused-label
 [2] https://gcc.gnu.org/onlinedocs/gcc/Common-Attributes.html#index-unused
 [3] https://godbolt.org/z/5sfjrdnns

Best Regards!
Luca

Reply via email to