This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Why does G++ not accept the unused attribute on labels ?


Hi Guys,

  Why does G++ not accept the unused attribute on labels ?

  For example if the attached test program - unused.c - is compiled
  with "gcc -c -Wall" there will be warnings issued for all of the
  unused_...2 symbols but none of the unused_...1 symbols.

  If however the file is renamed to unused.C and compiled with
  "g++ -c -Wall" then an error message will be generated for the
  definition of unused_label1 and it will also be reported as unused:

unused.C:15: error: expected primary-expression
unused.C:15: error: expected `;'
unused.C:15: warning: label `unused_label1' defined but not used

  Cheers
        Nick

---------------------------unused.c----------------------------------        
static int unused_static_variable1 __attribute__((__unused__)) = 1;
static int unused_static_variable2 = 2;

static int unused_function1 (void) __attribute__((__unused__));
static int unused_function2 (void);
static int unused_function1 (void) { return 3; }
static int unused_function2 (void) { return 4; }

int
func (void)
{
  int unused_local_variable1 __attribute__((__unused__)) = 5;
  int unused_local_variable2 = 6;

  unused_label1: __attribute__((__unused__))
  unused_label2:

  return 7;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]