* [PATCH 1/5] Fix an "'__sentinel__' attribute directive ignored" warning
@ 2007-05-22 17:58 Ramsay Jones
0 siblings, 0 replies; 4+ messages in thread
From: Ramsay Jones @ 2007-05-22 17:58 UTC (permalink / raw)
To: Josh Triplett; +Cc: Sparse Mailing-list
This attribute was introduced in gcc 3.5. My Cygwin install, which
is not that old, is using gcc 3.4.4.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
---
lib.h | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/lib.h b/lib.h
index df9cfc4..6902f91 100644
--- a/lib.h
+++ b/lib.h
@@ -68,10 +68,16 @@ typedef struct pseudo *pseudo_t;
struct token *skip_to(struct token *, int);
struct token *expect(struct token *, int, const char *);
#ifdef __GNUC__
+#define GCC_VERSION (__GNUC__ * 1000 + __GNUC__MINOR__)
#define FORMAT_ATTR(pos) __attribute__ ((__format__ (__printf__, pos, pos+1)))
#define NORETURN_ATTR __attribute__ ((__noreturn__))
+/* __sentinel__ attribute was introduced in gcc 3.5 */
+#if (GCC_VERSION >= 3005)
#define SENTINEL_ATTR __attribute__ ((__sentinel__))
#else
+#define SENTINEL_ATTR
+#endif /* gcc >= 3.5 */
+#else
#define FORMAT_ATTR(pos)
#define NORETURN_ATTR
#define SENTINEL_ATTR
--
1.5.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 1/5] Fix an "'__sentinel__' attribute directive ignored" warning
@ 2009-07-18 20:37 Ramsay Jones
2009-07-20 20:18 ` Christopher Li
0 siblings, 1 reply; 4+ messages in thread
From: Ramsay Jones @ 2009-07-18 20:37 UTC (permalink / raw)
To: Christopher Li; +Cc: Sparse Mailing-list
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(-)
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
--
1.6.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/5] Fix an "'__sentinel__' attribute directive ignored" warning
2009-07-18 20:37 [PATCH 1/5] Fix an "'__sentinel__' attribute directive ignored" warning Ramsay Jones
@ 2009-07-20 20:18 ` Christopher Li
2009-07-21 21:41 ` Ramsay Jones
0 siblings, 1 reply; 4+ messages in thread
From: Christopher Li @ 2009-07-20 20:18 UTC (permalink / raw)
To: Ramsay Jones; +Cc: Sparse Mailing-list
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/5] Fix an "'__sentinel__' attribute directive ignored" warning
2009-07-20 20:18 ` Christopher Li
@ 2009-07-21 21:41 ` Ramsay Jones
0 siblings, 0 replies; 4+ messages in thread
From: Ramsay Jones @ 2009-07-21 21:41 UTC (permalink / raw)
To: Christopher Li; +Cc: Sparse Mailing-list
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-07-21 21:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-18 20:37 [PATCH 1/5] Fix an "'__sentinel__' attribute directive ignored" warning Ramsay Jones
2009-07-20 20:18 ` Christopher Li
2009-07-21 21:41 ` Ramsay Jones
-- strict thread matches above, loose matches on Subject: below --
2007-05-22 17:58 Ramsay Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).