From 1da92cdd93a24538f24fcdc48a4ab6131f521cf9 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Fri, 8 Jul 2022 17:06:05 +0200 Subject: [PATCH] Accept attributes after labels newer GCC can associate attributes with statements and labels, this implements only the latter (and ignores the attributes). --- tccgen.c | 5 +++++ tests/tests2/82_attribs_position.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/tccgen.c b/tccgen.c index cc7cc9eb..daf489cf 100644 --- a/tccgen.c +++ b/tccgen.c @@ -7048,6 +7048,11 @@ again: s->cleanupstate = cur_scope->cl.s; block_after_label: + { + /* Accept attributes after labels (e.g. 'unused') */ + AttributeDef ad_tmp; + parse_attribute(&ad_tmp); + } vla_restore(cur_scope->vla.loc); if (tok != '}') goto again; diff --git a/tests/tests2/82_attribs_position.c b/tests/tests2/82_attribs_position.c index fd3f2c4e..d8c9fe5f 100644 --- a/tests/tests2/82_attribs_position.c +++ b/tests/tests2/82_attribs_position.c @@ -30,6 +30,12 @@ int ATTR actual_function() { return 42; } +int label_attribute (void) +{ +lab1: __attribute__((__unused__)); + return 0; +} + extern int printf (const char *, ...); static int globalvar; int main()