All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tomas Klacko <tomas.klacko@gmail.com>
To: Christopher Li <sparse@chrisli.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	Josh Triplett <josh@joshtriplett.org>,
	linux-sparse@vger.kernel.org
Subject: Re: including sparse headers in C++ code
Date: Sat, 16 Oct 2010 18:03:53 +0200	[thread overview]
Message-ID: <AANLkTimZb1PsnKcMQ_Ka6dkk7fNwXiJb6_U4GcckLsF4@mail.gmail.com> (raw)
In-Reply-To: <AANLkTimhh3zj8kgvaSQq9_CS711mLw8skrWL4yUgvJzT@mail.gmail.com>

Hi,

On Wed, Oct 13, 2010 at 2:37 AM, Christopher Li <sparse@chrisli.org> wrote:
> On Tue, Oct 12, 2010 at 3:45 PM, Tomas Klacko <tomas.klacko@gmail.com> wrote:

>> diff --git a/parse.h b/parse.h
>> index 6b21e23..f2193e7 100644
>> --- a/parse.h
>> +++ b/parse.h
>> @@ -35,10 +35,12 @@ struct statement {
>>                struct /* declaration */ {
>>                        struct symbol_list *declaration;
>>                };
>> +#ifndef __cplusplus
>>                struct /* label_arg */ {
>>                        struct symbol *label;
>>                        struct statement *label_statement;
>>                };
>> +#endif
>
> What is this #ifndef  for?

I use it to avoid this error:

[...]/sparse/parse.h:65: error: declaration of ‘statement*
statement::<anonymous union>::<anonymous struct>::label_statement’
[...]sparse/parse.h:41: error: conflicts with previous declaration
‘statement* statement::<anonymous union>::<anonymous
struct>::label_statement’

>>  /* Silly type-safety check ;) */
>>  #define DECLARE_PTR_LIST(listname,type)        struct listname { type *list[1]; }
>> -#define CHECK_TYPE(head,ptr)           (void)(&(ptr) == &(head)->list[0])
>>  #define TYPEOF(head)                   __typeof__(&(head)->list[0])
>>  #define VRFY_PTR_LIST(head)            (void)(sizeof((head)->list[0]))
>>
>> +#ifndef __cplusplus
>> +#define CHECK_TYPE(head,ptr)           (void)(&(ptr) == &(head)->list[0])
>> +#else
>> +/* I don't know yet how to do this better in C++. */
>> +#define CHECK_TYPE(head,ptr) (void)((void*)&(ptr) == (void*)&(head)->list[0])
>> +#endif
>
> If you can't get CHECK_TYPE work in C++, you might just make it an empty define
> instead of doing useless point dancing. At least it is clear that it does not
> do any thing here.

True. How about
#define CHECK_TYPE (head,ptr)   (void)(1)
?

I have processed your comments and this is the next patch version:

From df482c2ca34900186667ca68ca8dbbbe9a14f798 Mon Sep 17 00:00:00 2001
From: Tomas Klacko <tomas.klacko@gmail.com>
Date: Sat, 16 Oct 2010 15:48:27 +0200
Subject: [PATCH] Make headers usable in Cxx code.

---
 c2xml.c       |    6 +++---
 ctags.c       |    6 +++---
 expression.c  |   12 ++++++------
 expression.h  |    6 +++---
 graph.c       |    2 +-
 lib.h         |   13 +++++++------
 linearize.h   |    4 ++--
 parse.c       |   22 +++++++++++-----------
 parse.h       |    2 ++
 pre-process.c |   10 +++++-----
 ptrlist.h     |   12 +++++++++---
 symbol.c      |   10 +++++-----
 symbol.h      |   15 ++++++++-------
 token.h       |    4 ++--
 14 files changed, 67 insertions(+), 57 deletions(-)

diff --git a/c2xml.c b/c2xml.c
index 37f29cf..749c699 100644
--- a/c2xml.c
+++ b/c2xml.c
@@ -128,7 +128,7 @@ static void examine_modifiers(struct symbol *sym,
xmlNodePtr node)

 	int i;

-	if (sym->namespace != NS_SYMBOL)
+	if (sym->ns != NS_SYMBOL)
 		return;

 	/*iterate over the 32 bit bitfield*/
@@ -236,7 +236,7 @@ static void examine_namespace(struct symbol *sym)
 	if (sym->ident && sym->ident->reserved)
 		return;

-	switch(sym->namespace) {
+	switch(sym->ns) {
 	case NS_MACRO:
 		examine_macro(sym, root_node);
 		break;
@@ -253,7 +253,7 @@ static void examine_namespace(struct symbol *sym)
 	case NS_KEYWORD:
 		break;
 	default:
-		die("Unrecognised namespace type %d",sym->namespace);
+		die("Unrecognised namespace type %d",sym->ns);
 	}

 }
diff --git a/ctags.c b/ctags.c
index 7e129a6..7e09c95 100644
--- a/ctags.c
+++ b/ctags.c
@@ -145,7 +145,7 @@ static void examine_symbol(struct symbol *sym)

 	default:
 		die("unknown symbol %s namespace:%d type:%d\n", show_ident(sym->ident),
-		    sym->namespace, sym->type);
+		    sym->ns, sym->type);
 	}
 	if (!sym->kind)
 		sym->kind = 'v';
@@ -159,7 +159,7 @@ static void examine_namespace(struct symbol *sym)
 	if (sym->ident && sym->ident->reserved)
 		return;

-	switch(sym->namespace) {
+	switch(sym->ns) {
 	case NS_KEYWORD:
 	case NS_PREPROCESSOR:
 		return;
@@ -177,7 +177,7 @@ static void examine_namespace(struct symbol *sym)
 		examine_symbol(sym);
 		break;
 	default:
-		die("unknown namespace %d symbol:%s type:%d\n", sym->namespace,
+		die("unknown namespace %d symbol:%s type:%d\n", sym->ns,
 		    show_ident(sym->ident), sym->type);
 	}
 	add_tag(sym);
diff --git a/expression.c b/expression.c
index 7e06e60..e02f5b0 100644
--- a/expression.c
+++ b/expression.c
@@ -118,7 +118,7 @@ static struct token *parse_type(struct token
*token, struct expression **tree)
 	struct symbol *sym;
 	*tree = alloc_expression(token->pos, EXPR_TYPE);
 	(*tree)->flags = Int_const_expr; /* sic */
-	token = typename(token, &sym, NULL);
+	token = type_name(token, &sym, NULL);
 	if (sym->ident)
 		sparse_error(token->pos,
 			     "type expression should not include identifier "
@@ -167,7 +167,7 @@ static struct token *builtin_offsetof_expr(struct
token *token,
 		return expect(token, '(', "after __builtin_offset");

 	token = token->next;
-	token = typename(token, &sym, NULL);
+	token = type_name(token, &sym, NULL);
 	if (sym->ident)
 		sparse_error(token->pos,
 			     "type expression should not include identifier "
@@ -455,7 +455,7 @@ struct token *primary_expression(struct token
*token, struct expression **tree)
 		 *
 		 *	if (typeof(a) == int) ..
 		 */
-		if (sym && sym->namespace == NS_TYPEDEF) {
+		if (sym && sym->ns == NS_TYPEDEF) {
 			sparse_error(token->pos, "typename in expression");
 			sym = NULL;
 		}
@@ -486,7 +486,7 @@ struct token *primary_expression(struct token
*token, struct expression **tree)
 		if (token->special == '[' && lookup_type(token->next)) {
 			expr = alloc_expression(token->pos, EXPR_TYPE);
 			expr->flags = Int_const_expr; /* sic */
-			token = typename(token->next, &expr->symbol, NULL);
+			token = type_name(token->next, &expr->symbol, NULL);
 			token = expect(token, ']', "in type expression");
 			break;
 		}
@@ -606,7 +606,7 @@ static struct token *type_info_expression(struct
token *token,
 	if (!match_op(token, '(') || !lookup_type(token->next))
 		return unary_expression(token, &expr->cast_expression);
 	p = token;
-	token = typename(token->next, &expr->cast_type, NULL);
+	token = type_name(token->next, &expr->cast_type, NULL);

 	if (!match_op(token, ')')) {
 		static const char * error[] = {
@@ -731,7 +731,7 @@ static struct token *cast_expression(struct token
*token, struct expression **tr
 			struct symbol *sym;
 			int is_force;

-			token = typename(next, &sym, &is_force);
+			token = type_name(next, &sym, &is_force);
 			cast->cast_type = sym;
 			token = expect(token, ')', "at end of cast operator");
 			if (match_op(token, '{')) {
diff --git a/expression.h b/expression.h
index 9778de8..698c778 100644
--- a/expression.h
+++ b/expression.h
@@ -196,13 +196,13 @@ static inline struct expression
*alloc_const_expression(struct position pos, int
 }

 /* Type name parsing */
-struct token *typename(struct token *, struct symbol **, int *);
+struct token *type_name(struct token *, struct symbol **, int *);

 static inline int lookup_type(struct token *token)
 {
 	if (token->pos.type == TOKEN_IDENT) {
-		struct symbol *sym = lookup_symbol(token->ident, NS_SYMBOL | NS_TYPEDEF);
-		return sym && (sym->namespace & NS_TYPEDEF);
+		struct symbol *sym = lookup_symbol(token->ident, NS_SYMBOL_OR_TYPEDEF);
+		return sym && (sym->ns & NS_TYPEDEF);
 	}
 	return 0;
 }
diff --git a/graph.c b/graph.c
index 1a77d75..7e0868f 100644
--- a/graph.c
+++ b/graph.c
@@ -124,7 +124,7 @@ static void graph_calls(struct entrypoint *ep, int internal)
 				if (insn->func->type == PSEUDO_SYM) {
 					for (sym = insn->func->sym->ident->symbols;
 					     sym; sym = sym->next_id) {
-						if (sym->namespace & NS_SYMBOL && sym->ep)
+						if (sym->ns & NS_SYMBOL && sym->ep)
 							break;
 					}

diff --git a/lib.h b/lib.h
index 2cea252..6d24fc8 100644
--- a/lib.h
+++ b/lib.h
@@ -164,31 +164,32 @@ static inline void free_instruction_list(struct
instruction_list **head)

 static inline struct instruction * delete_last_instruction(struct
instruction_list **head)
 {
-	return undo_ptr_list_last((struct ptr_list **)head);
+	return (struct instruction *)undo_ptr_list_last((struct ptr_list **)head);
 }

 static inline struct basic_block * delete_last_basic_block(struct
basic_block_list **head)
 {
-	return delete_ptr_list_last((struct ptr_list **)head);
+	return (struct basic_block *)delete_ptr_list_last((struct ptr_list **)head);
 }

 static inline struct basic_block *first_basic_block(struct
basic_block_list *head)
 {
-	return first_ptr_list((struct ptr_list *)head);
+	return (struct basic_block *)first_ptr_list((struct ptr_list *)head);
 }
+
 static inline struct instruction *last_instruction(struct
instruction_list *head)
 {
-	return last_ptr_list((struct ptr_list *)head);
+	return (struct instruction *)last_ptr_list((struct ptr_list *)head);
 }

 static inline struct instruction *first_instruction(struct
instruction_list *head)
 {
-	return first_ptr_list((struct ptr_list *)head);
+	return (struct instruction *)first_ptr_list((struct ptr_list *)head);
 }

 static inline pseudo_t first_pseudo(struct pseudo_list *head)
 {
-	return first_ptr_list((struct ptr_list *)head);
+	return (pseudo_t)first_ptr_list((struct ptr_list *)head);
 }

 static inline void concat_symbol_list(struct symbol_list *from,
struct symbol_list **to)
diff --git a/linearize.h b/linearize.h
index 50b3601..a6d629f 100644
--- a/linearize.h
+++ b/linearize.h
@@ -314,9 +314,9 @@ static inline void remove_bb_from_list(struct
basic_block_list **list, struct ba
 }

 static inline void replace_bb_in_list(struct basic_block_list **list,
-	struct basic_block *old, struct basic_block *new, int count)
+	struct basic_block *old, struct basic_block *newlist, int count)
 {
-	replace_ptr_list_entry((struct ptr_list **)list, old, new, count);
+	replace_ptr_list_entry((struct ptr_list **)list, old, newlist, count);
 }

 struct entrypoint {
diff --git a/parse.c b/parse.c
index 537055f..0f6fc4b 100644
--- a/parse.c
+++ b/parse.c
@@ -188,7 +188,7 @@ static struct symbol_op char_op = {
 	.type = KW_SPECIFIER,
 	.test = Set_T|Set_Long|Set_Short,
 	.set = Set_T|Set_Char,
-	.class = CChar,
+	.klass = CChar,
 };

 static struct symbol_op int_op = {
@@ -201,14 +201,14 @@ static struct symbol_op double_op = {
 	.type = KW_SPECIFIER,
 	.test = Set_T|Set_Signed|Set_Unsigned|Set_Short|Set_Vlong,
 	.set = Set_T|Set_Double,
-	.class = CReal,
+	.klass = CReal,
 };

 static struct symbol_op float_op = {
 	.type = KW_SPECIFIER | KW_SHORT,
 	.test = Set_T|Set_Signed|Set_Unsigned|Set_Short|Set_Long,
 	.set = Set_T|Set_Float,
-	.class = CReal,
+	.klass = CReal,
 };

 static struct symbol_op short_op = {
@@ -221,14 +221,14 @@ static struct symbol_op signed_op = {
 	.type = KW_SPECIFIER,
 	.test = Set_S|Set_Float|Set_Double|Set_Signed|Set_Unsigned,
 	.set = Set_Signed,
-	.class = CSInt,
+	.klass = CSInt,
 };

 static struct symbol_op unsigned_op = {
 	.type = KW_SPECIFIER,
 	.test = Set_S|Set_Float|Set_Double|Set_Signed|Set_Unsigned,
 	.set = Set_Unsigned,
-	.class = CUInt,
+	.klass = CUInt,
 };

 static struct symbol_op long_op = {
@@ -364,7 +364,7 @@ static struct symbol_op mode_word_op = {

 static struct init_keyword {
 	const char *name;
-	enum namespace ns;
+	enum name_space ns;
 	unsigned long modifiers;
 	struct symbol_op *op;
 	struct symbol *type;
@@ -979,7 +979,7 @@ static struct token *typeof_specifier(struct token
*token, struct decl_state *ct
 		return token;
 	}
 	if (lookup_type(token->next)) {
-		token = typename(token->next, &sym, NULL);
+		token = type_name(token->next, &sym, NULL);
 		ctx->ctype.base_type = sym->ctype.base_type;
 		apply_ctype(token->pos, &sym->ctype, &ctx->ctype);
 	} else {
@@ -1433,7 +1433,7 @@ static struct token
*declaration_specifiers(struct token *token, struct decl_sta
 	while (token_type(token) == TOKEN_IDENT) {
 		struct symbol *s = lookup_symbol(token->ident,
 						 NS_TYPEDEF | NS_SYMBOL);
-		if (!s || !(s->namespace & NS_TYPEDEF))
+		if (!s || !(s->ns & NS_TYPEDEF))
 			break;
 		if (s->type != SYM_KEYWORD) {
 			if (seen & Set_Any)
@@ -1452,7 +1452,7 @@ static struct token
*declaration_specifiers(struct token *token, struct decl_sta
 				break;
 			}
 			seen |= s->op->set;
-			class += s->op->class;
+			class += s->op->klass;
 			if (s->op->type & KW_SHORT) {
 				size = -1;
 			} else if (s->op->type & KW_LONG && size++) {
@@ -1831,7 +1831,7 @@ static struct token
*parameter_declaration(struct token *token, struct symbol *s
 	return token;
 }

-struct token *typename(struct token *token, struct symbol **p, int *forced)
+struct token *type_name(struct token *token, struct symbol **p, int *forced)
 {
 	struct decl_state ctx = {.prefer_abstract = 1};
 	int class;
@@ -2295,7 +2295,7 @@ static struct token *label_statement(struct token *token)
 		struct symbol *sym = alloc_symbol(token->pos, SYM_LABEL);
 		/* it's block-scope, but we want label namespace */
 		bind_symbol(sym, token->ident, NS_SYMBOL);
-		sym->namespace = NS_LABEL;
+		sym->ns = NS_LABEL;
 		fn_local_symbol(sym);
 		token = token->next;
 		if (!match_op(token, ','))
diff --git a/parse.h b/parse.h
index 6b21e23..f2193e7 100644
--- a/parse.h
+++ b/parse.h
@@ -35,10 +35,12 @@ struct statement {
 		struct /* declaration */ {
 			struct symbol_list *declaration;
 		};
+#ifndef __cplusplus
 		struct /* label_arg */ {
 			struct symbol *label;
 			struct statement *label_statement;
 		};
+#endif
 		struct {
 			struct expression *expression;
 			struct expression *context;
diff --git a/pre-process.c b/pre-process.c
index 656acaa..b7371f3 100644
--- a/pre-process.c
+++ b/pre-process.c
@@ -109,7 +109,7 @@ static void replace_with_integer(struct token
*token, unsigned int val)
 static struct symbol *lookup_macro(struct ident *ident)
 {
 	struct symbol *sym = lookup_symbol(ident, NS_MACRO | NS_UNDEF);
-	if (sym && sym->namespace != NS_MACRO)
+	if (sym && sym->ns != NS_MACRO)
 		sym = NULL;
 	return sym;
 }
@@ -1146,7 +1146,7 @@ static int do_handle_define(struct stream
*stream, struct token **line, struct t
 		if (attr < sym->attr)
 			goto out;

-		clean = (attr == sym->attr && sym->namespace == NS_MACRO);
+		clean = (attr == sym->attr && sym->ns == NS_MACRO);

 		if (token_list_different(sym->expansion, expansion) ||
 		    token_list_different(sym->arglist, arglist)) {
@@ -1173,7 +1173,7 @@ static int do_handle_define(struct stream
*stream, struct token **line, struct t
 		__free_token(token);	/* Free the "define" token, but not the rest
of the line */
 	}

-	sym->namespace = NS_MACRO;
+	sym->ns = NS_MACRO;
 	sym->used_in = NULL;
 	sym->attr = attr;
 out:
@@ -1209,7 +1209,7 @@ static int do_handle_undef(struct stream
*stream, struct token **line, struct to
 	if (sym) {
 		if (attr < sym->attr)
 			return 1;
-		if (attr == sym->attr && sym->namespace == NS_UNDEF)
+		if (attr == sym->attr && sym->ns == NS_UNDEF)
 			return 1;
 	} else if (attr <= SYM_ATTR_NORMAL)
 		return 1;
@@ -1219,7 +1219,7 @@ static int do_handle_undef(struct stream
*stream, struct token **line, struct to
 		bind_symbol(sym, left->ident, NS_MACRO);
 	}

-	sym->namespace = NS_UNDEF;
+	sym->ns = NS_UNDEF;
 	sym->used_in = NULL;
 	sym->attr = attr;

diff --git a/ptrlist.h b/ptrlist.h
index fbfc080..99e50da 100644
--- a/ptrlist.h
+++ b/ptrlist.h
@@ -14,10 +14,16 @@

 /* Silly type-safety check ;) */
 #define DECLARE_PTR_LIST(listname,type)	struct listname { type *list[1]; }
-#define CHECK_TYPE(head,ptr)		(void)(&(ptr) == &(head)->list[0])
 #define TYPEOF(head)			__typeof__(&(head)->list[0])
 #define VRFY_PTR_LIST(head)		(void)(sizeof((head)->list[0]))

+#ifndef __cplusplus
+#define CHECK_TYPE(head,ptr)		(void)(&(ptr) == &(head)->list[0])
+#else
+/* I don't know yet how to do this better in C++. */
+#define CHECK_TYPE(head,ptr)   (void)(1)
+#endif
+
 /*
  * The "unnecessary" statement expression is there to shut up a totally
  * bogus gcc warning about unused expressions, brought on by the fact
@@ -39,7 +45,7 @@ struct ptr_list {
 void * undo_ptr_list_last(struct ptr_list **head);
 void * delete_ptr_list_last(struct ptr_list **head);
 int delete_ptr_list_entry(struct ptr_list **, void *, int);
-int replace_ptr_list_entry(struct ptr_list **, void *old, void *new, int);
+int replace_ptr_list_entry(struct ptr_list **, void *old, void *newlist, int);
 extern void sort_list(struct ptr_list **, int (*)(const void *, const void *));

 extern void **__add_ptr_list(struct ptr_list **, void *, unsigned long);
@@ -270,7 +276,7 @@ extern void pack_ptr_list(struct ptr_list **);

 static inline void update_tag(void *p, unsigned long tag)
 {
-	unsigned long *ptr = p;
+	unsigned long *ptr = (unsigned long *)p;
 	*ptr = tag | (~3UL & *ptr);
 }

diff --git a/symbol.c b/symbol.c
index 96dfbfa..a8cd999 100644
--- a/symbol.c
+++ b/symbol.c
@@ -39,12 +39,12 @@ void access_symbol(struct symbol *sym)
 	}
 }

-struct symbol *lookup_symbol(struct ident *ident, enum namespace ns)
+struct symbol *lookup_symbol(struct ident *ident, enum name_space ns)
 {
 	struct symbol *sym;

 	for (sym = ident->symbols; sym; sym = sym->next_id) {
-		if (sym->namespace & ns) {
+		if (sym->ns & ns) {
 			sym->used = 1;
 			return sym;
 		}
@@ -515,7 +515,7 @@ void check_declaration(struct symbol *sym)
 	struct symbol *next = sym;

 	while ((next = next->next_id) != NULL) {
-		if (next->namespace != sym->namespace)
+		if (next->ns != sym->ns)
 			continue;
 		if (sym->scope == next->scope) {
 			sym->same_symbol = next;
@@ -538,7 +538,7 @@ void check_declaration(struct symbol *sym)
 	}
 }

-void bind_symbol(struct symbol *sym, struct ident *ident, enum namespace ns)
+void bind_symbol(struct symbol *sym, struct ident *ident, enum name_space ns)
 {
 	struct scope *scope;
 	if (sym->bound) {
@@ -549,7 +549,7 @@ void bind_symbol(struct symbol *sym, struct ident
*ident, enum namespace ns)
 		sparse_error(sym->pos, "Trying to use reserved word '%s' as
identifier", show_ident(ident));
 		return;
 	}
-	sym->namespace = ns;
+	sym->ns = ns;
 	sym->next_id = ident->symbols;
 	ident->symbols = sym;
 	if (sym->ident && sym->ident != ident)
diff --git a/symbol.h b/symbol.h
index e567305..a483096 100644
--- a/symbol.h
+++ b/symbol.h
@@ -24,13 +24,14 @@
  * token contains the information on where the symbol was
  * declared.
  */
-enum namespace {
+enum name_space {
 	NS_NONE = 0,
 	NS_MACRO = 1,
 	NS_TYPEDEF = 2,
 	NS_STRUCT = 4,  // Also used for unions and enums.
 	NS_LABEL = 8,
 	NS_SYMBOL = 16,
+	NS_SYMBOL_OR_TYPEDEF = 18,
 	NS_ITERATOR = 32,
 	NS_PREPROCESSOR = 64,
 	NS_UNDEF = 128,
@@ -109,7 +110,7 @@ struct symbol_op {
 	struct token *(*attribute)(struct token *token, struct symbol *attr,
struct decl_state *ctx);
 	struct symbol *(*to_mode)(struct symbol *);

-	int test, set, class;
+	int test, set, klass;
 };

 extern int expand_safe_p(struct expression *expr, int cost);
@@ -121,7 +122,7 @@ extern int expand_constant_p(struct expression
*expr, int cost);

 struct symbol {
 	enum type type:8;
-	enum namespace namespace:9;
+	enum name_space ns:9;
 	unsigned char used:1, attr:2, enum_member:1, bound:1;
 	struct position pos;		/* Where this symbol was declared */
 	struct position endpos;		/* Where this symbol ends*/
@@ -267,8 +268,8 @@ extern void access_symbol(struct symbol *);
 extern const char * type_difference(struct ctype *c1, struct ctype *c2,
 	unsigned long mod1, unsigned long mod2);

-extern struct symbol *lookup_symbol(struct ident *, enum namespace);
-extern struct symbol *create_symbol(int stream, const char *name, int
type, int namespace);
+extern struct symbol *lookup_symbol(struct ident *, enum name_space);
+extern struct symbol *create_symbol(int stream, const char *name, int
type, int name_space);
 extern void init_symbols(void);
 extern void init_ctype(void);
 extern struct symbol *alloc_symbol(struct position, int type);
@@ -279,7 +280,7 @@ extern int show_symbol_expr_init(struct symbol *sym);
 extern void show_type_list(struct symbol *);
 extern void show_symbol_list(struct symbol_list *, const char *);
 extern void add_symbol(struct symbol_list **, struct symbol *);
-extern void bind_symbol(struct symbol *, struct ident *, enum namespace);
+extern void bind_symbol(struct symbol *, struct ident *, enum name_space);

 extern struct symbol *examine_symbol_type(struct symbol *);
 extern struct symbol *examine_pointer_target(struct symbol *);
@@ -367,7 +368,7 @@ static inline int get_sym_type(struct symbol *type)
 	return type->type;
 }

-static inline struct symbol *lookup_keyword(struct ident *ident, enum
namespace ns)
+static inline struct symbol *lookup_keyword(struct ident *ident, enum
name_space ns)
 {
 	if (!ident->keyword)
 		return NULL;
diff --git a/token.h b/token.h
index a7ec77e..fd854a0 100644
--- a/token.h
+++ b/token.h
@@ -175,7 +175,7 @@ struct token {
 static inline struct token *containing_token(struct token **p)
 {
 	void *addr = (char *)p - ((char *)&((struct token *)0)->next - (char *)0);
-	return addr;
+	return (struct token*)addr;
 }

 #define token_type(x) ((x)->pos.type)
@@ -205,7 +205,7 @@ extern struct token *preprocess(struct token *);

 static inline int match_op(struct token *token, int op)
 {
-	return token->pos.type == TOKEN_SPECIAL && token->special == op;
+	return token->pos.type == TOKEN_SPECIAL && token->special == (unsigned int)op;
 }

 static inline int match_ident(struct token *token, struct ident *id)
-- 
1.5.4.3


Also, I have notices this:

lib.h:static inline void add_symbol(struct symbol_list **list, struct
symbol *sym)
symbol.h:extern void add_symbol(struct symbol_list **, struct symbol *);

but I did not find add_symbol definition in *.c.
What's the purpose?

Tomas Klacko
--
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

  parent reply	other threads:[~2010-10-16 16:04 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-09 16:40 including sparse headers in C++ code Tomas Klacko
2010-10-09 20:59 ` Josh Triplett
2010-10-09 21:46   ` Christopher Li
2010-10-10 11:41     ` Bernd Petrovitsch
2010-10-10 11:52       ` Kamil Dudka
2010-10-11  9:44         ` Bernd Petrovitsch
2010-10-11 16:04           ` Christopher Li
2010-10-11 19:12             ` Josh Triplett
2010-10-13 14:45               ` Bernd Petrovitsch
2010-10-18 18:43                 ` Christopher Li
2010-10-20  7:29                 ` Al Viro
2010-10-20  9:39                   ` Bernd Petrovitsch
2010-10-20 15:34                     ` Christopher Li
2010-10-29 13:22                       ` Bernd Petrovitsch
2010-11-05  0:57                         ` Christopher Li
2010-11-09 13:28                           ` Bernd Petrovitsch
2010-11-09 22:52                             ` Christopher Li
2010-11-10 10:52                               ` Bernd Petrovitsch
2010-10-11 22:33     ` Tomas Klacko
2010-10-11 22:46       ` Al Viro
2010-10-11 23:01         ` Christopher Li
2010-10-12 22:45           ` Tomas Klacko
2010-10-13  0:37             ` Christopher Li
2010-10-13 11:39               ` Bernd Petrovitsch
2010-10-16 16:03               ` Tomas Klacko [this message]
2010-10-16 19:11                 ` Josh Triplett
2010-10-17 10:31                   ` Tomas Klacko
2010-10-18  4:13                     ` Christopher Li
2010-10-18  5:39                     ` Josh Triplett
2010-10-18 18:37                       ` Christopher Li
2010-10-19 20:03                         ` Tomas Klacko
2010-10-19 21:31                           ` Al Viro
2010-10-19 21:46                             ` David Malcolm
2010-10-19 22:12                               ` Al Viro
2010-10-19 22:49                             ` Tomas Klacko
2010-10-20 10:19                               ` Bernd Petrovitsch
2010-10-19 23:07                             ` Christopher Li
2010-10-20  7:40                               ` Al Viro
2010-10-18  3:16                   ` Christopher Li
2010-10-11 23:37       ` Josh Triplett
2010-10-12 10:42         ` Bernd Petrovitsch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AANLkTimZb1PsnKcMQ_Ka6dkk7fNwXiJb6_U4GcckLsF4@mail.gmail.com \
    --to=tomas.klacko@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.