diff mbox

[1/5] Fix an "'__sentinel__' attribute directive ignored" warning

Message ID 4A62329B.9040107@ramsay1.demon.co.uk (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Ramsay Jones July 18, 2009, 8:37 p.m. UTC
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).

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---

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(-)

Comments

Christopher Li July 20, 2009, 8:18 p.m. UTC | #1
On Sat, Jul 18, 2009 at 1:37 PM, Ramsay Jones<ramsay@ramsay1.demon.co.uk> wrote:
>
> 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).

Can you elaborate the error message you received?
A small test program would be great.

Thanks

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ramsay Jones July 21, 2009, 9:41 p.m. UTC | #2
Christopher Li wrote:
> On Sat, Jul 18, 2009 at 1:37 PM, Ramsay Jones<ramsay@ramsay1.demon.co.uk> wrote:
>> 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).
> 
> 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

--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/lib.h b/lib.h
index b22fa93..919b5b1 100644
--- a/lib.h
+++ b/lib.h
@@ -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