Fix an "'__sentinel__' attribute directive ignored" warning
PATCH 1/5 Fix an "'__sentinel__' attribute directive ignored" warning
This attribute was introduced in gcc 3.5. In order to avoid such warnings, add a gcc version check when defining the SENTINEL_ATTR macro. (This warning message, in particular, was issued by a gcc 3.4.4 compiler).
---
Hi Chris,
I had some, somewhat old, patches kicking around in my sparse repo which may be useful; so I'm sending them along for your consideration.
For this patch, an alternative solution (which I haven't tried) would be to add -Wno-attributes to CFLAGS.
ATB,
Ramsay Jones
lib.h | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
lib.h +5 -1
@@ -70,7 +70,11 @@ struct token *expect(struct token *, int, const char *);#ifdef __GNUC__#define FORMAT_ATTR (pos) __attribute__ ((__format__ (__printf__, pos, pos+1)))#define NORETURN_ATTR __attribute__ ((__noreturn__)) -#define SENTINEL_ATTR __attribute__ ((__sentinel__)) +#if ((__GNUC__ *100 + __GNUC__MINOR__) >=305 )/* gcc version >= 3.5 */ +# define SENTINEL_ATTR __attribute__ ((__sentinel__)) +#else +# define SENTINEL_ATTR +#endif #else #define FORMAT_ATTR (pos)#define NORETURN_ATTR
Signature · 1 line
1.6.3.1
Christopher Li
maintainerQuoted 5 lines · Ramsay Jones
This attribute was introduced in gcc 3.5. In order to avoid such warnings, add a gcc version check when defining the
SENTINEL_ATTRmacro. (This warning message, in particular, was issued by a gcc 3.4.4 compiler).
Can you elaborate the error message you received?
A small test program would be great.
Thanks
Chris
Quoted 10 lines · Christopher Li
Quoted 4 lines · Ramsay Jones
This attribute was introduced in gcc 3.5. In order to avoid such warnings, add a gcc version check when defining the
SENTINEL_ATTRmacro. (This warning message, in particular, was issued by a gcc 3.4.4 compiler).Can you elaborate the error message you received?
A small test program would be great.Thanks
$ touch parse.c
$ make OS=cygwin parse.o
CC parse.o
parse.c:558: warning: `__sentinel__' attribute directive ignored
parse.c: In function `external_declaration':
parse.c:2619: warning: enumeration value `SYM_UNINITIALIZED' not handled in switch
parse.c:2619: warning: enumeration value `SYM_PREPROCESSOR' not handled in switch
parse.c:2619: warning: enumeration value `SYM_BASETYPE' not handled in switch
parse.c:2619: warning: enumeration value `SYM_NODE' not handled in switch
parse.c:2619: warning: enumeration value `SYM_PTR' not handled in switch
parse.c:2619: warning: enumeration value `SYM_FN' not handled in switch
parse.c:2619: warning: enumeration value `SYM_ARRAY' not handled in switch
parse.c:2619: warning: enumeration value `SYM_TYPEDEF' not handled in switch
parse.c:2619: warning: enumeration value `SYM_TYPEOF' not handled in switch
parse.c:2619: warning: enumeration value `SYM_MEMBER' not handled in switch
parse.c:2619: warning: enumeration value `SYM_BITFIELD' not handled in switch
parse.c:2619: warning: enumeration value `SYM_LABEL' not handled in switch
parse.c:2619: warning: enumeration value `SYM_FOULED' not handled in switch
parse.c:2619: warning: enumeration value `SYM_KEYWORD' not handled in switch
parse.c:2619: warning: enumeration value `SYM_BAD' not handled in switch
$Note the first gcc warning. (The other warnings relate to patch #2) Maybe this is easier to see:
$ make OS=cygwin CFLAGS=-Wno-switch-enum parse.o
CC parse.o
parse.c:558: warning: `__sentinel__' attribute directive ignored
$ Note also, that gcc 3.4.4 does not understand -Wno-attributes. (ie I tried that alternative and it didn't work :( ).
My cygwin installation is about 2 years old and, unfortunately, I can't update it on this machine. (The current cygwin gcc is at version 4.3.0). Since this is due to an old gcc, maybe the simplest thing is for me to just keep rebasing this patch in my cygwin repo. I don't need it on Linux.
ATB,
Ramsay Jones