* including sparse headers in C++ code
@ 2010-10-09 16:40 Tomas Klacko
2010-10-09 20:59 ` Josh Triplett
0 siblings, 1 reply; 41+ messages in thread
From: Tomas Klacko @ 2010-10-09 16:40 UTC (permalink / raw)
To: linux-sparse
Hi,
I am including sparse headers in a C++ code,
but this does not work because of the use of keywords
like new and namespace, (and retyping).
What is your stance on this?
I mean, would you accept a patch or is there
some other way which I have missed?
Thanks,
Tomas Klacko
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
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
0 siblings, 1 reply; 41+ messages in thread
From: Josh Triplett @ 2010-10-09 20:59 UTC (permalink / raw)
To: Tomas Klacko; +Cc: linux-sparse
On Sat, Oct 09, 2010 at 06:40:26PM +0200, Tomas Klacko wrote:
> I am including sparse headers in a C++ code,
> but this does not work because of the use of keywords
> like new and namespace, (and retyping).
>
> What is your stance on this?
> I mean, would you accept a patch or is there
> some other way which I have missed?
It seems reasonable to avoid the use of C++ keywords in Sparse *headers*
(though unnecessary in *source*). Looks like this will primarily cause
pain due to "enum namespace" and the various places using it. Seems
easy enough to change those all to "ns". "new" mostly seems to get used
as a parameter name or local variable name; for the former we could omit
it, and for the latter we could trivially call it something more
specific like "newlist" or "newptr".
So, I'd tend to guess "patches welcome" (again, for headers only, plus
minimal corresponding source changes when required). I wouldn't
anticipate other Sparse developers objecting strongly, but if they do
your mail seems like the right way to find out. The various reasons
given for *not* making the Linux kernel headers compatible don't seem to
apply here, though.
- Josh Triplett
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-09 20:59 ` Josh Triplett
@ 2010-10-09 21:46 ` Christopher Li
2010-10-10 11:41 ` Bernd Petrovitsch
2010-10-11 22:33 ` Tomas Klacko
0 siblings, 2 replies; 41+ messages in thread
From: Christopher Li @ 2010-10-09 21:46 UTC (permalink / raw)
To: Josh Triplett; +Cc: Tomas Klacko, linux-sparse
On Sat, Oct 9, 2010 at 1:59 PM, Josh Triplett <josh@joshtriplett.org> wrote:
> It seems reasonable to avoid the use of C++ keywords in Sparse *headers*
> (though unnecessary in *source*). Looks like this will primarily cause
> pain due to "enum namespace" and the various places using it. Seems
> easy enough to change those all to "ns". "new" mostly seems to get used
> as a parameter name or local variable name; for the former we could omit
> it, and for the latter we could trivially call it something more
> specific like "newlist" or "newptr".
>
> So, I'd tend to guess "patches welcome" (again, for headers only, plus
> minimal corresponding source changes when required). I wouldn't
> anticipate other Sparse developers objecting strongly, but if they do
> your mail seems like the right way to find out. The various reasons
> given for *not* making the Linux kernel headers compatible don't seem to
> apply here, though.
Well said. I don't expect sparse to compile in the C++ mode. Making
sparse header usable in C++ seems reasonable to me.
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
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-09 21:46 ` Christopher Li
@ 2010-10-10 11:41 ` Bernd Petrovitsch
2010-10-10 11:52 ` Kamil Dudka
2010-10-11 22:33 ` Tomas Klacko
1 sibling, 1 reply; 41+ messages in thread
From: Bernd Petrovitsch @ 2010-10-10 11:41 UTC (permalink / raw)
To: Christopher Li; +Cc: Josh Triplett, Tomas Klacko, linux-sparse
On Sam, 2010-10-09 at 14:46 -0700, Christopher Li wrote:
> On Sat, Oct 9, 2010 at 1:59 PM, Josh Triplett <josh@joshtriplett.org> wrote:
> > It seems reasonable to avoid the use of C++ keywords in Sparse *headers*
> > (though unnecessary in *source*). Looks like this will primarily cause
> > pain due to "enum namespace" and the various places using it. Seems
> > easy enough to change those all to "ns". "new" mostly seems to get used
> > as a parameter name or local variable name; for the former we could omit
> > it, and for the latter we could trivially call it something more
> > specific like "newlist" or "newptr".
> >
> > So, I'd tend to guess "patches welcome" (again, for headers only, plus
> > minimal corresponding source changes when required). I wouldn't
> > anticipate other Sparse developers objecting strongly, but if they do
> > your mail seems like the right way to find out. The various reasons
> > given for *not* making the Linux kernel headers compatible don't seem to
> > apply here, though.
>
> Well said. I don't expect sparse to compile in the C++ mode. Making
> sparse header usable in C++ seems reasonable to me.
Well, sparse uses C99.
If one #include's <stdbool.h> at some day (as I did;-), than "true" and
"false" don't work any longer that good as variable names.
Are (trivial) patches to simply rename them appreciated?
Bernd
--
Bernd Petrovitsch Email : bernd@petrovitsch.priv.at
LUGA : http://www.luga.at
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-10 11:41 ` Bernd Petrovitsch
@ 2010-10-10 11:52 ` Kamil Dudka
2010-10-11 9:44 ` Bernd Petrovitsch
0 siblings, 1 reply; 41+ messages in thread
From: Kamil Dudka @ 2010-10-10 11:52 UTC (permalink / raw)
To: Bernd Petrovitsch
Cc: Christopher Li, Josh Triplett, Tomas Klacko, linux-sparse
On Sunday 10 October 2010 13:41:59 Bernd Petrovitsch wrote:
> On Sam, 2010-10-09 at 14:46 -0700, Christopher Li wrote:
> > On Sat, Oct 9, 2010 at 1:59 PM, Josh Triplett <josh@joshtriplett.org>
wrote:
> > > It seems reasonable to avoid the use of C++ keywords in Sparse
> > > *headers* (though unnecessary in *source*). Looks like this will
> > > primarily cause pain due to "enum namespace" and the various places
> > > using it. Seems easy enough to change those all to "ns". "new" mostly
> > > seems to get used as a parameter name or local variable name; for the
> > > former we could omit it, and for the latter we could trivially call it
> > > something more specific like "newlist" or "newptr".
> > >
> > > So, I'd tend to guess "patches welcome" (again, for headers only, plus
> > > minimal corresponding source changes when required). I wouldn't
> > > anticipate other Sparse developers objecting strongly, but if they do
> > > your mail seems like the right way to find out. The various reasons
> > > given for *not* making the Linux kernel headers compatible don't seem
> > > to apply here, though.
> >
> > Well said. I don't expect sparse to compile in the C++ mode. Making
> > sparse header usable in C++ seems reasonable to me.
>
> Well, sparse uses C99.
> If one #include's <stdbool.h> at some day (as I did;-), than "true" and
> "false" don't work any longer that good as variable names.
The clash of sparse headers with <stdbool.h> should be already fixed:
http://git.kernel.org/?p=devel/sparse/sparse.git;a=commitdiff;h=0be55c9
Kamil
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-10 11:52 ` Kamil Dudka
@ 2010-10-11 9:44 ` Bernd Petrovitsch
2010-10-11 16:04 ` Christopher Li
0 siblings, 1 reply; 41+ messages in thread
From: Bernd Petrovitsch @ 2010-10-11 9:44 UTC (permalink / raw)
To: Kamil Dudka; +Cc: Christopher Li, Josh Triplett, Tomas Klacko, linux-sparse
On Son, 2010-10-10 at 13:52 +0200, Kamil Dudka wrote:
> On Sunday 10 October 2010 13:41:59 Bernd Petrovitsch wrote:
> > On Sam, 2010-10-09 at 14:46 -0700, Christopher Li wrote:
[...]
> > > Well said. I don't expect sparse to compile in the C++ mode. Making
> > > sparse header usable in C++ seems reasonable to me.
> >
> > Well, sparse uses C99.
> > If one #include's <stdbool.h> at some day (as I did;-), than "true" and
> > "false" don't work any longer that good as variable names.
>
> The clash of sparse headers with <stdbool.h> should be already fixed:
>
> http://git.kernel.org/?p=devel/sparse/sparse.git;a=commitdiff;h=0be55c9
So far so good IMHO. But:
---- snip ----
{102}egrep -wc 'false|true' *.[ch] | grep -v :0
compile-i386.c:19
evaluate.c:13
expand.c:10
flow.c:10
inline.c:13
linearize.c:6
pre-process.c:3
show-parse.c:3
simplify.c:9
symbol.c:1
tokenize.c:1
---- snip ----
There are perhaps false positives in there - but not all.
Perhaps 'sparse' should warn if one names variables, functions, and
similar "true", "false" or with any other C99 keyword.
For C++ keywords, a different option is probably best.
Bernd
--
mobile: +43 664 4416156 http://www.sysprog.at/
Linux Software Development, Consulting and Services
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-11 9:44 ` Bernd Petrovitsch
@ 2010-10-11 16:04 ` Christopher Li
2010-10-11 19:12 ` Josh Triplett
0 siblings, 1 reply; 41+ messages in thread
From: Christopher Li @ 2010-10-11 16:04 UTC (permalink / raw)
To: Bernd Petrovitsch; +Cc: Kamil Dudka, Josh Triplett, Tomas Klacko, linux-sparse
On Mon, Oct 11, 2010 at 2:44 AM, Bernd Petrovitsch <bernd@sysprog.at> wrote:
> ---- snip ----
> {102}egrep -wc 'false|true' *.[ch] | grep -v :0
> compile-i386.c:19
> evaluate.c:13
> expand.c:10
> flow.c:10
> inline.c:13
> linearize.c:6
> pre-process.c:3
> show-parse.c:3
> simplify.c:9
> symbol.c:1
> tokenize.c:1
> ---- snip ----
> There are perhaps false positives in there - but not all.
>
> Perhaps 'sparse' should warn if one names variables, functions, and
> similar "true", "false" or with any other C99 keyword.
> For C++ keywords, a different option is probably best.
>
Those are not used in header files they should be fine. Sparse uses
C99 extensively
so it is likely it can't compile as C++ any way. I see no reason to
compile sparse
with C++.
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
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-11 16:04 ` Christopher Li
@ 2010-10-11 19:12 ` Josh Triplett
2010-10-13 14:45 ` Bernd Petrovitsch
0 siblings, 1 reply; 41+ messages in thread
From: Josh Triplett @ 2010-10-11 19:12 UTC (permalink / raw)
To: Christopher Li; +Cc: Bernd Petrovitsch, Kamil Dudka, Tomas Klacko, linux-sparse
On Mon, Oct 11, 2010 at 09:04:18AM -0700, Christopher Li wrote:
> On Mon, Oct 11, 2010 at 2:44 AM, Bernd Petrovitsch <bernd@sysprog.at> wrote:
> > ---- snip ----
> > {102}egrep -wc 'false|true' *.[ch] | grep -v :0
> > compile-i386.c:19
> > evaluate.c:13
> > expand.c:10
> > flow.c:10
> > inline.c:13
> > linearize.c:6
> > pre-process.c:3
> > show-parse.c:3
> > simplify.c:9
> > symbol.c:1
> > tokenize.c:1
> > ---- snip ----
> > There are perhaps false positives in there - but not all.
> >
> > Perhaps 'sparse' should warn if one names variables, functions, and
> > similar "true", "false" or with any other C99 keyword.
> > For C++ keywords, a different option is probably best.
>
> Those are not used in header files they should be fine. Sparse uses
> C99 extensively
> so it is likely it can't compile as C++ any way. I see no reason to
> compile sparse
> with C++.
Actually, Sparse seems to use "true" and "false" as variable names in
several cases; for instance:
static struct symbol *evaluate_conditional_expression(struct expression *expr)
{
struct expression **true;
[...]
true = &expr->conditional;
I think this only works because evaluate.c doesn't include stdbool.h.
And sure enough, if I include stdbool.h from evaluate.c:
CC evaluate.o
evaluate.c: In function ‘evaluate_conditional_expression’:
evaluate.c:1081: error: expected identifier or ‘(’ before numeric constant
evaluate.c:1095: error: lvalue required as left operand of assignment
evaluate.c:1101: error: lvalue required as left operand of assignment
evaluate.c:1106: error: invalid type argument of ‘unary *’ (have ‘int’)
evaluate.c:1114: error: invalid type argument of ‘unary *’ (have ‘int’)
evaluate.c:1116: error: invalid type argument of ‘unary *’ (have ‘int’)
evaluate.c:1116: error: invalid type argument of ‘unary *’ (have ‘int’)
evaluate.c:1122: error: invalid type argument of ‘unary *’ (have ‘int’)
evaluate.c:1126: error: invalid type argument of ‘unary *’ (have ‘int’)
evaluate.c:1126: error: invalid type argument of ‘unary *’ (have ‘int’)
evaluate.c:1133: error: invalid type argument of ‘unary *’ (have ‘int’)
evaluate.c:1134: error: invalid type argument of ‘unary *’ (have ‘int’)
evaluate.c:1134: error: invalid type argument of ‘unary *’ (have ‘int’)
evaluate.c:1202: error: invalid type argument of ‘unary *’ (have ‘int’)
evaluate.c:1202: error: invalid type argument of ‘unary *’ (have ‘int’)
I agree with Bernd: I think Sparse should have a warning for using
"true", "false", or "bool" as an identifier of any kind. That would
necessitate some way to avoid such warnings for the actual definitions
in stdbool.h. Alternatively, Sparse could warn about using "true" or
"false" as anything other than values, and about using "bool" as
anything other than a type; that would allow for projects that define
their own bool in a compatible way.
- Josh Triplett
--
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
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-09 21:46 ` Christopher Li
2010-10-10 11:41 ` Bernd Petrovitsch
@ 2010-10-11 22:33 ` Tomas Klacko
2010-10-11 22:46 ` Al Viro
2010-10-11 23:37 ` Josh Triplett
1 sibling, 2 replies; 41+ messages in thread
From: Tomas Klacko @ 2010-10-11 22:33 UTC (permalink / raw)
To: Christopher Li; +Cc: Josh Triplett, linux-sparse
Hi,
On Sat, Oct 9, 2010 at 11:46 PM, Christopher Li <sparse@chrisli.org> wrote:
> On Sat, Oct 9, 2010 at 1:59 PM, Josh Triplett <josh@joshtriplett.org> wrote:
>> It seems reasonable to avoid the use of C++ keywords in Sparse *headers*
>> (though unnecessary in *source*). Looks like this will primarily cause
>> pain due to "enum namespace" and the various places using it. Seems
>> easy enough to change those all to "ns". "new" mostly seems to get used
>> as a parameter name or local variable name; for the former we could omit
>> it, and for the latter we could trivially call it something more
>> specific like "newlist" or "newptr".
>>
>> So, I'd tend to guess "patches welcome" (again, for headers only, plus
>> minimal corresponding source changes when required). I wouldn't
>> anticipate other Sparse developers objecting strongly, but if they do
>> your mail seems like the right way to find out. The various reasons
>> given for *not* making the Linux kernel headers compatible don't seem to
>> apply here, though.
>
> Well said. I don't expect sparse to compile in the C++ mode. Making
> sparse header usable in C++ seems reasonable to me.
Great. I am posting my current status (as a patch) so that you can comment on it
and that I can refine it further.
This is the patch:
From 2a7094f02181b06afbe593daab6992d7539b618a Mon Sep 17 00:00:00 2001
From: Tomas Klacko <tomas.klacko@gmail.com>
Date: Mon, 11 Oct 2010 09:50:14 +0200
Subject: [PATCH] Make headers usable in C++ code.
---
c2xml.c | 6 ++--
compile-i386.c | 10 ++++----
ctags.c | 6 ++--
evaluate.c | 68 ++++++++++++++++++++++++++++----------------------------
expression.c | 12 +++++-----
expression.h | 7 +++--
graph.c | 2 +-
lib.h | 38 ++++++++++++++++++++++---------
linearize.h | 4 +-
parse.c | 50 ++++++++++++++++++++--------------------
parse.h | 5 +++-
pre-process.c | 10 ++++----
ptrlist.h | 16 ++++++++++--
show-parse.c | 8 +++---
symbol.c | 14 +++++-----
symbol.h | 14 +++++-----
token.h | 5 ++-
tokenize.c | 12 +++++-----
18 files changed, 159 insertions(+), 128 deletions(-)
diff --git a/c2xml.c b/c2xml.c
index 37f29cf..e5b64a0 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->Namespace != 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->Namespace) {
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->Namespace);
}
}
diff --git a/compile-i386.c b/compile-i386.c
index abe9313..0a08e86 100644
--- a/compile-i386.c
+++ b/compile-i386.c
@@ -332,9 +332,9 @@ busy:
return 1;
}
-static struct storage *get_reg(struct regclass *class)
+static struct storage *get_reg(struct regclass *Class)
{
- const unsigned char *regs = class->regs;
+ const unsigned char *regs = Class->regs;
int regno;
while ((regno = *regs) != NOREG) {
@@ -343,11 +343,11 @@ static struct storage *get_reg(struct regclass *class)
continue;
return get_hardreg(hardreg_storage_table + regno, 1);
}
- fprintf(stderr, "Ran out of %s registers\n", class->name);
+ fprintf(stderr, "Ran out of %s registers\n", Class->name);
exit(1);
}
-static struct storage *get_reg_value(struct storage *value, struct
regclass *class)
+static struct storage *get_reg_value(struct storage *value, struct
regclass *Class)
{
struct reg_info *info;
struct storage *reg;
@@ -359,7 +359,7 @@ static struct storage *get_reg_value(struct
storage *value, struct regclass *cla
return get_hardreg(hardreg_storage_table + info->own_regno, 0);
}
- reg = get_reg(class);
+ reg = get_reg(Class);
emit_move(value, reg, value->ctype, "reload register");
info = reg->reg;
info->contains = value;
diff --git a/ctags.c b/ctags.c
index 7e129a6..cd4e508 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->Namespace, 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->Namespace) {
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->Namespace,
show_ident(sym->ident), sym->type);
}
add_tag(sym);
diff --git a/evaluate.c b/evaluate.c
index f8343c2..0baf92b 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -357,7 +357,7 @@ static inline int classify_type(struct symbol
*type, struct symbol **base)
return type_class[type->type];
}
-#define is_int(class) ((class & (TYPE_NUM | TYPE_FLOAT)) == TYPE_NUM)
+#define is_int(Class) ((Class & (TYPE_NUM | TYPE_FLOAT)) == TYPE_NUM)
static inline int is_string_type(struct symbol *type)
{
@@ -480,10 +480,10 @@ static struct symbol *restricted_binop_type(int op,
}
static inline void unrestrict(struct expression *expr,
- int class, struct symbol **ctype)
+ int Class, struct symbol **ctype)
{
- if (class & TYPE_RESTRICT) {
- if (class & TYPE_FOULED)
+ if (Class & TYPE_RESTRICT) {
+ if (Class & TYPE_FOULED)
*ctype = unfoul(*ctype);
warning(expr->pos, "%s degrades to integer",
show_typename(*ctype));
@@ -1696,7 +1696,7 @@ static struct symbol *evaluate_postop(struct
expression *expr)
{
struct expression *op = expr->unop;
struct symbol *ctype = op->ctype;
- int class = classify_type(op->ctype, &ctype);
+ int Class = classify_type(op->ctype, &ctype);
int multiply = 0;
if (!lvalue_expression(expr->unop)) {
@@ -1704,12 +1704,12 @@ static struct symbol *evaluate_postop(struct
expression *expr)
return NULL;
}
- if ((class & TYPE_RESTRICT) && restricted_unop(expr->op, &ctype))
+ if ((Class & TYPE_RESTRICT) && restricted_unop(expr->op, &ctype))
return bad_expr_type(expr);
- if (class & TYPE_NUM) {
+ if (Class & TYPE_NUM) {
multiply = 1;
- } else if (class == TYPE_PTR) {
+ } else if (Class == TYPE_PTR) {
struct symbol *target = examine_pointer_target(ctype);
if (!is_function(target))
multiply = bits_to_bytes(target->bit_size);
@@ -1729,19 +1729,19 @@ static struct symbol *evaluate_postop(struct
expression *expr)
static struct symbol *evaluate_sign(struct expression *expr)
{
struct symbol *ctype = expr->unop->ctype;
- int class = classify_type(ctype, &ctype);
+ int Class = classify_type(ctype, &ctype);
if (expr->flags && !(expr->unop->flags & Int_const_expr))
expr->flags = 0;
/* should be an arithmetic type */
- if (!(class & TYPE_NUM))
+ if (!(Class & TYPE_NUM))
return bad_expr_type(expr);
- if (!(class & (TYPE_FLOAT|TYPE_RESTRICT))) {
+ if (!(Class & (TYPE_FLOAT|TYPE_RESTRICT))) {
struct symbol *rtype = integer_promotion(ctype);
expr->unop = cast_to(expr->unop, rtype);
ctype = rtype;
- } else if ((class & TYPE_FLOAT) && expr->op != '~') {
+ } else if ((Class & TYPE_FLOAT) && expr->op != '~') {
/* no conversions needed */
- } else if ((class & TYPE_RESTRICT) && !restricted_unop(expr->op, &ctype)) {
+ } else if ((Class & TYPE_RESTRICT) && !restricted_unop(expr->op, &ctype)) {
/* no conversions needed */
} else {
return bad_expr_type(expr);
@@ -2111,14 +2111,14 @@ static int evaluate_arguments(struct symbol
*f, struct symbol *fn, struct expres
target = argtype;
if (!target) {
struct symbol *type;
- int class = classify_type(ctype, &type);
- if (is_int(class)) {
+ int Class = classify_type(ctype, &type);
+ if (is_int(Class)) {
*p = cast_to(expr, integer_promotion(type));
- } else if (class & TYPE_FLOAT) {
+ } else if (Class & TYPE_FLOAT) {
unsigned long mod = type->ctype.modifiers;
if (!(mod & (MOD_LONG_ALL)))
*p = cast_to(expr, &double_ctype);
- } else if (class & TYPE_PTR) {
+ } else if (Class & TYPE_PTR) {
if (expr->ctype == &null_ctype)
*p = cast_to(expr, &ptr_ctype);
else
@@ -2191,7 +2191,7 @@ static void excess(struct expression *e, const char *s)
/*
* implicit designator for the first element
*/
-static struct expression *first_subobject(struct symbol *ctype, int class,
+static struct expression *first_subobject(struct symbol *ctype, int Class,
struct expression **v)
{
struct expression *e = *v, *new;
@@ -2199,7 +2199,7 @@ static struct expression *first_subobject(struct
symbol *ctype, int class,
if (ctype->type == SYM_NODE)
ctype = ctype->ctype.base_type;
- if (class & TYPE_PTR) { /* array */
+ if (Class & TYPE_PTR) { /* array */
if (!ctype->bit_size)
return NULL;
new = alloc_expression(e->pos, EXPR_INDEX);
@@ -2351,13 +2351,13 @@ static struct expression
*next_designators(struct expression *old,
}
static int handle_simple_initializer(struct expression **ep, int nested,
- int class, struct symbol *ctype);
+ int Class, struct symbol *ctype);
/*
* deal with traversing subobjects [6.7.8(17,18,20)]
*/
static void handle_list_initializer(struct expression *expr,
- int class, struct symbol *ctype)
+ int Class, struct symbol *ctype)
{
struct expression *e, *last = NULL, *top = NULL, *next;
int jumped = 0;
@@ -2371,12 +2371,12 @@ static void handle_list_initializer(struct
expression *expr,
struct symbol *struct_sym;
if (!top) {
top = e;
- last = first_subobject(ctype, class, &top);
+ last = first_subobject(ctype, Class, &top);
} else {
last = next_designators(last, ctype, e, &top);
}
if (!last) {
- excess(e, class & TYPE_PTR ? "array" :
+ excess(e, Class & TYPE_PTR ? "array" :
"struct or union");
DELETE_CURRENT_PTR(e);
continue;
@@ -2508,7 +2508,7 @@ static struct expression *handle_scalar(struct
expression *e, int nested)
* until we dig into the inner struct.
*/
static int handle_simple_initializer(struct expression **ep, int nested,
- int class, struct symbol *ctype)
+ int Class, struct symbol *ctype)
{
int is_string = is_string_type(ctype);
struct expression *e = *ep, *p;
@@ -2518,7 +2518,7 @@ static int handle_simple_initializer(struct
expression **ep, int nested,
return 0;
/* scalar */
- if (!(class & TYPE_COMPOUND)) {
+ if (!(Class & TYPE_COMPOUND)) {
e = handle_scalar(e, nested);
if (!e)
return 0;
@@ -2548,7 +2548,7 @@ static int handle_simple_initializer(struct
expression **ep, int nested,
goto String;
}
}
- handle_list_initializer(e, class, ctype);
+ handle_list_initializer(e, Class, ctype);
return 1;
}
@@ -2562,7 +2562,7 @@ static int handle_simple_initializer(struct
expression **ep, int nested,
return 0;
}
/* struct or union can be initialized by compatible */
- if (class != TYPE_COMPOUND)
+ if (Class != TYPE_COMPOUND)
return 0;
type = evaluate_expression(e);
if (!type)
@@ -2591,8 +2591,8 @@ String:
static void evaluate_initializer(struct symbol *ctype, struct expression **ep)
{
struct symbol *type;
- int class = classify_type(ctype, &type);
- if (!handle_simple_initializer(ep, 0, class, ctype))
+ int Class = classify_type(ctype, &type);
+ if (!handle_simple_initializer(ep, 0, Class, ctype))
expression_error(*ep, "invalid initializer");
}
@@ -2820,7 +2820,7 @@ static struct symbol *evaluate_offsetof(struct
expression *expr)
{
struct expression *e = expr->down;
struct symbol *ctype = expr->in;
- int class;
+ int Class;
if (expr->op == '.') {
struct symbol *field;
@@ -2830,8 +2830,8 @@ static struct symbol *evaluate_offsetof(struct
expression *expr)
return NULL;
}
examine_symbol_type(ctype);
- class = classify_type(ctype, &ctype);
- if (class != TYPE_COMPOUND) {
+ Class = classify_type(ctype, &ctype);
+ if (Class != TYPE_COMPOUND) {
expression_error(expr, "expected structure or union");
return NULL;
}
@@ -2853,8 +2853,8 @@ static struct symbol *evaluate_offsetof(struct
expression *expr)
return NULL;
}
examine_symbol_type(ctype);
- class = classify_type(ctype, &ctype);
- if (class != (TYPE_COMPOUND | TYPE_PTR)) {
+ Class = classify_type(ctype, &ctype);
+ if (Class != (TYPE_COMPOUND | TYPE_PTR)) {
expression_error(expr, "expected array");
return NULL;
}
diff --git a/expression.c b/expression.c
index 7e06e60..5f68c77 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 = Typename(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 = Typename(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->Namespace == 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 = Typename(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 = Typename(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 = Typename(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..57617b2 100644
--- a/expression.h
+++ b/expression.h
@@ -196,13 +196,14 @@ static inline struct expression
*alloc_const_expression(struct position pos, int
}
/* Type name parsing */
-struct token *typename(struct token *, struct symbol **, int *);
+struct token *Typename(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,
+ (enum Namespace)(NS_SYMBOL | NS_TYPEDEF) );
+ return sym && (sym->Namespace & NS_TYPEDEF);
}
return 0;
}
diff --git a/graph.c b/graph.c
index 1a77d75..cd55f1c 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->Namespace & NS_SYMBOL && sym->ep)
break;
}
diff --git a/lib.h b/lib.h
index 2cea252..95c9973 100644
--- a/lib.h
+++ b/lib.h
@@ -120,6 +120,10 @@ extern int Wdeclarationafterstatement;
extern int dbg_entry;
extern int dbg_dead;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
extern void declare_builtin_functions(void);
extern void create_builtin_stream(void);
extern struct symbol_list *sparse_initialize(int argc, char **argv,
struct string_list **files);
@@ -127,6 +131,10 @@ extern struct symbol_list *__sparse(char *filename);
extern struct symbol_list *sparse_keep_tokens(char *filename);
extern struct symbol_list *sparse(char *filename);
+#ifdef __cplusplus
+}
+#endif
+
static inline int symbol_list_size(struct symbol_list *list)
{
return ptr_list_size((struct ptr_list *)(list));
@@ -162,33 +170,41 @@ static inline void free_instruction_list(struct
instruction_list **head)
free_ptr_list((struct ptr_list **)head);
}
-static inline struct instruction * delete_last_instruction(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)
+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)
+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)
+
+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)
+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..9aeb5e2 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 *_new, int count)
{
- replace_ptr_list_entry((struct ptr_list **)list, old, new, count);
+ replace_ptr_list_entry((struct ptr_list **)list, old, _new, count);
}
struct entrypoint {
diff --git a/parse.c b/parse.c
index 537055f..a885fbd 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,
+ .Class = 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,
+ .Class = 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,
+ .Class = 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,
+ .Class = 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,
+ .Class = 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 Namespace 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 = Typename(token->next, &sym, NULL);
ctx->ctype.base_type = sym->ctype.base_type;
apply_ctype(token->pos, &sym->ctype, &ctx->ctype);
} else {
@@ -1249,21 +1249,21 @@ static unsigned long storage_modifiers(struct
decl_state *ctx)
| (ctx->is_tls ? MOD_TLS : 0);
}
-static void set_storage_class(struct position *pos, struct decl_state
*ctx, int class)
+static void set_storage_class(struct position *pos, struct decl_state
*ctx, int Class)
{
/* __thread can be used alone, or with extern or static */
- if (ctx->is_tls && (class != SStatic && class != SExtern)) {
+ if (ctx->is_tls && (Class != SStatic && Class != SExtern)) {
sparse_error(*pos, "__thread can only be used alone, or with "
"extern or static");
return;
}
if (!ctx->storage_class) {
- ctx->storage_class = class;
+ ctx->storage_class = Class;
return;
}
- if (ctx->storage_class == class)
- sparse_error(*pos, "duplicate %s", storage_class[class]);
+ if (ctx->storage_class == Class)
+ sparse_error(*pos, "duplicate %s", storage_class[Class]);
else
sparse_error(*pos, "multiple storage classes");
}
@@ -1427,13 +1427,13 @@ static struct token *handle_qualifiers(struct
token *t, struct decl_state *ctx)
static struct token *declaration_specifiers(struct token *token,
struct decl_state *ctx)
{
int seen = 0;
- int class = CInt;
+ int Class = CInt;
int size = 0;
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->Namespace & NS_TYPEDEF))
break;
if (s->type != SYM_KEYWORD) {
if (seen & Set_Any)
@@ -1452,11 +1452,11 @@ static struct token
*declaration_specifiers(struct token *token, struct decl_sta
break;
}
seen |= s->op->set;
- class += s->op->class;
+ Class += s->op->Class;
if (s->op->type & KW_SHORT) {
size = -1;
} else if (s->op->type & KW_LONG && size++) {
- if (class == CReal) {
+ if (Class == CReal) {
specifier_conflict(token->pos,
Set_Vlong,
&double_ident);
@@ -1477,7 +1477,7 @@ static struct token
*declaration_specifiers(struct token *token, struct decl_sta
if (!(seen & Set_S)) { /* not set explicitly? */
struct symbol *base = &incomplete_ctype;
if (seen & Set_Any)
- base = types[class][size];
+ base = types[Class][size];
ctx->ctype.base_type = base;
}
@@ -1831,10 +1831,10 @@ 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 *Typename(struct token *token, struct symbol **p, int *forced)
{
struct decl_state ctx = {.prefer_abstract = 1};
- int class;
+ int Class;
struct symbol *sym = alloc_symbol(token->pos, SYM_NODE);
*p = sym;
token = declaration_specifiers(token, &ctx);
@@ -1842,17 +1842,17 @@ struct token *typename(struct token *token,
struct symbol **p, int *forced)
apply_modifiers(token->pos, &ctx);
sym->ctype = ctx.ctype;
sym->endpos = token->pos;
- class = ctx.storage_class;
+ Class = ctx.storage_class;
if (forced) {
*forced = 0;
- if (class == SForced) {
+ if (Class == SForced) {
*forced = 1;
- class = 0;
+ Class = 0;
}
}
- if (class)
+ if (Class)
warning(sym->pos, "storage class in typename (%s %s)",
- storage_class[class], show_typename(sym));
+ storage_class[Class], show_typename(sym));
return token;
}
@@ -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->Namespace = NS_LABEL;
fn_local_symbol(sym);
token = token->next;
if (!match_op(token, ','))
diff --git a/parse.h b/parse.h
index 6b21e23..56e23e6 100644
--- a/parse.h
+++ b/parse.h
@@ -28,6 +28,7 @@ enum statement_type {
STMT_RANGE,
};
+
struct statement {
enum statement_type type;
struct position pos;
@@ -35,10 +36,12 @@ struct statement {
struct /* declaration */ {
struct symbol_list *declaration;
};
- struct /* label_arg */ {
+ /*
+ struct / * label_arg * / {
struct symbol *label;
struct statement *label_statement;
};
+ */
struct {
struct expression *expression;
struct expression *context;
diff --git a/pre-process.c b/pre-process.c
index 656acaa..bdd6419 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->Namespace != 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->Namespace == 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->Namespace = 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->Namespace == 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->Namespace = NS_UNDEF;
sym->used_in = NULL;
sym->attr = attr;
diff --git a/ptrlist.h b/ptrlist.h
index fbfc080..5d246b4 100644
--- a/ptrlist.h
+++ b/ptrlist.h
@@ -14,7 +14,8 @@
/* 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 CHECK_TYPE(head,ptr) (void)((void*)&(ptr) == (void*)&(head)->list[0])
+//#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]))
@@ -36,10 +37,14 @@ struct ptr_list {
#define ptr_list_empty(x) ((x) == NULL)
+#ifdef __cplusplus
+extern "C" {
+#endif
+
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 *_new, int);
extern void sort_list(struct ptr_list **, int (*)(const void *, const void *));
extern void **__add_ptr_list(struct ptr_list **, void *, unsigned long);
@@ -48,6 +53,11 @@ extern void __free_ptr_list(struct ptr_list **);
extern int ptr_list_size(struct ptr_list *);
extern int linearize_ptr_list(struct ptr_list *, void **, int);
+#ifdef __cplusplus
+}
+#endif
+
+
/*
* Hey, who said that you can't do overloading in C?
*
@@ -270,7 +280,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/show-parse.c b/show-parse.c
index c97debe..7f8938a 100644
--- a/show-parse.c
+++ b/show-parse.c
@@ -257,7 +257,7 @@ const char *builtin_ctypename(struct ctype *ctype)
static void do_show_type(struct symbol *sym, struct type_name *name)
{
- const char *typename;
+ const char *Typename;
unsigned long mod = 0;
int as = 0;
int was_ptr = 0;
@@ -284,12 +284,12 @@ deeper:
if (!sym)
goto out;
- if ((typename = builtin_typename(sym))) {
- int len = strlen(typename);
+ if ((Typename = builtin_typename(sym))) {
+ int len = strlen(Typename);
if (name->start != name->end)
*--name->start = ' ';
name->start -= len;
- memcpy(name->start, typename, len);
+ memcpy(name->start, Typename, len);
goto out;
}
diff --git a/symbol.c b/symbol.c
index 96dfbfa..845f3ae 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 Namespace ns)
{
struct symbol *sym;
for (sym = ident->symbols; sym; sym = sym->next_id) {
- if (sym->namespace & ns) {
+ if (sym->Namespace & 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->Namespace != sym->Namespace)
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 Namespace 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->Namespace = ns;
sym->next_id = ident->symbols;
ident->symbols = sym;
if (sym->ident && sym->ident != ident)
@@ -576,12 +576,12 @@ void bind_symbol(struct symbol *sym, struct
ident *ident, enum namespace ns)
bind_scope(sym, scope);
}
-struct symbol *create_symbol(int stream, const char *name, int type,
int namespace)
+struct symbol *create_symbol(int stream, const char *name, int type,
int Namespace)
{
struct token *token = built_in_token(stream, name);
struct symbol *sym = alloc_symbol(token->pos, type);
- bind_symbol(sym, token->ident, namespace);
+ bind_symbol(sym, token->ident, Namespace);
return sym;
}
diff --git a/symbol.h b/symbol.h
index e567305..6118d00 100644
--- a/symbol.h
+++ b/symbol.h
@@ -24,7 +24,7 @@
* token contains the information on where the symbol was
* declared.
*/
-enum namespace {
+enum Namespace {
NS_NONE = 0,
NS_MACRO = 1,
NS_TYPEDEF = 2,
@@ -109,7 +109,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, Class;
};
extern int expand_safe_p(struct expression *expr, int cost);
@@ -121,7 +121,7 @@ extern int expand_constant_p(struct expression
*expr, int cost);
struct symbol {
enum type type:8;
- enum namespace namespace:9;
+ enum Namespace Namespace: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 +267,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 Namespace);
+extern struct symbol *create_symbol(int stream, const char *name, int
type, int Namespace);
extern void init_symbols(void);
extern void init_ctype(void);
extern struct symbol *alloc_symbol(struct position, int type);
@@ -279,7 +279,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 Namespace);
extern struct symbol *examine_symbol_type(struct symbol *);
extern struct symbol *examine_pointer_target(struct symbol *);
@@ -367,7 +367,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
Namespace ns)
{
if (!ident->keyword)
return NULL;
diff --git a/token.h b/token.h
index a7ec77e..9dcd525 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,8 @@ 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)
diff --git a/tokenize.c b/tokenize.c
index 4c97517..c88a5a2 100644
--- a/tokenize.c
+++ b/tokenize.c
@@ -406,13 +406,13 @@ static int get_one_number(int c, int next,
stream_t *stream)
*p++ = c;
for (;;) {
- long class = cclass[next + 1];
- if (!(class & (Dot | Digit | Letter)))
+ long Class = cclass[next + 1];
+ if (!(Class & (Dot | Digit | Letter)))
break;
if (p != buffer_end)
*p++ = next;
next = nextchar(stream);
- if (class & Exp) {
+ if (Class & Exp) {
if (next == '-' || next == '+') {
if (p != buffer_end)
*p++ = next;
@@ -899,10 +899,10 @@ static int get_one_identifier(int c, stream_t *stream)
static int get_one_token(int c, stream_t *stream)
{
- long class = cclass[c + 1];
- if (class & Digit)
+ long Class = cclass[c + 1];
+ if (Class & Digit)
return get_one_number(c, nextchar(stream), stream);
- if (class & Letter)
+ if (Class & Letter)
return get_one_identifier(c, stream);
return get_one_special(c, stream);
}
--
1.5.4.3
Few notes from me. In the header files, I made changes to keywords
new, namespace, class, typename, (plus I inserted explicit retyping
where the g++ compiler needed it). As a result, I also made changes
(renaming) in the source code. But now I see, that not all of the class->Class
renaming in *.c files is necessary, and I should probably undo it.
Also for consistency, I should probably go through and check the rest
of the headers
(for instance putting extern "C" to all function declarations).
Something I wasn't clearly
thinking about with my first email :-)
So far, this (pseudo) code passes "g++ -Wall -Werror":
// start
#include "lib.h"
#include "allocate.h"
#include "token.h"
#include "parse.h"
#include "symbol.h"
#include "expression.h"
#include "linearize.h"
int main(int argc, *argv[])
{
sparse_initialize();
concat_symbol_list();
}
// end
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
^ permalink raw reply related [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-11 22:33 ` Tomas Klacko
@ 2010-10-11 22:46 ` Al Viro
2010-10-11 23:01 ` Christopher Li
2010-10-11 23:37 ` Josh Triplett
1 sibling, 1 reply; 41+ messages in thread
From: Al Viro @ 2010-10-11 22:46 UTC (permalink / raw)
To: Tomas Klacko; +Cc: Christopher Li, Josh Triplett, linux-sparse
On Tue, Oct 12, 2010 at 12:33:32AM +0200, Tomas Klacko wrote:
> Great. I am posting my current status (as a patch) so that you can comment on it
> and that I can refine it further.
ehh... Use of capitalized variable names is a Bad Idea(tm). Especially
since you are doing that well outside of headers, so even compatibility
with Straustrups's Mistake does not serve as a reason.
> -#define CHECK_TYPE(head,ptr) (void)(&(ptr) == &(head)->list[0])
> +#define CHECK_TYPE(head,ptr) (void)((void*)&(ptr) == (void*)&(head)->list[0])
WTF? You do realize that it defeats the only purpose of this thing?
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-11 22:46 ` Al Viro
@ 2010-10-11 23:01 ` Christopher Li
2010-10-12 22:45 ` Tomas Klacko
0 siblings, 1 reply; 41+ messages in thread
From: Christopher Li @ 2010-10-11 23:01 UTC (permalink / raw)
To: Al Viro; +Cc: Tomas Klacko, Josh Triplett, linux-sparse
On Mon, Oct 11, 2010 at 3:46 PM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> On Tue, Oct 12, 2010 at 12:33:32AM +0200, Tomas Klacko wrote:
>
>> Great. I am posting my current status (as a patch) so that you can comment on it
>> and that I can refine it further.
>
> ehh... Use of capitalized variable names is a Bad Idea(tm). Especially
> since you are doing that well outside of headers, so even compatibility
> with Straustrups's Mistake does not serve as a reason.
I am about to complain the same thing. Al beats me to it.
Tomas, can you limit the change on the header file C++ friendly first?
I don't think the rest of the C code need to be compile in C++, so it is fine
using C++ key words.
Al, while you are here. What do you say regarding the true/false symbol name
conflict with stdbool.h? I am fine with either way, more leading toward leave it
as it is for now.
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
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-11 22:33 ` Tomas Klacko
2010-10-11 22:46 ` Al Viro
@ 2010-10-11 23:37 ` Josh Triplett
2010-10-12 10:42 ` Bernd Petrovitsch
1 sibling, 1 reply; 41+ messages in thread
From: Josh Triplett @ 2010-10-11 23:37 UTC (permalink / raw)
To: Tomas Klacko; +Cc: Christopher Li, linux-sparse
On Tue, Oct 12, 2010 at 12:33:32AM +0200, Tomas Klacko wrote:
> On Sat, Oct 9, 2010 at 11:46 PM, Christopher Li <sparse@chrisli.org> wrote:
> > On Sat, Oct 9, 2010 at 1:59 PM, Josh Triplett <josh@joshtriplett.org> wrote:
> >> It seems reasonable to avoid the use of C++ keywords in Sparse *headers*
> >> (though unnecessary in *source*). Looks like this will primarily cause
> >> pain due to "enum namespace" and the various places using it. Seems
> >> easy enough to change those all to "ns". "new" mostly seems to get used
> >> as a parameter name or local variable name; for the former we could omit
> >> it, and for the latter we could trivially call it something more
> >> specific like "newlist" or "newptr".
> >>
> >> So, I'd tend to guess "patches welcome" (again, for headers only, plus
> >> minimal corresponding source changes when required). I wouldn't
> >> anticipate other Sparse developers objecting strongly, but if they do
> >> your mail seems like the right way to find out. The various reasons
> >> given for *not* making the Linux kernel headers compatible don't seem to
> >> apply here, though.
> >
> > Well said. I don't expect sparse to compile in the C++ mode. Making
> > sparse header usable in C++ seems reasonable to me.
>
> Great. I am posting my current status (as a patch) so that you can comment on it
> and that I can refine it further.
> --- 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->Namespace != NS_SYMBOL)
How about "ns"?
> --- a/compile-i386.c
> +++ b/compile-i386.c
> @@ -332,9 +332,9 @@ busy:
> return 1;
> }
>
> -static struct storage *get_reg(struct regclass *class)
> +static struct storage *get_reg(struct regclass *Class)
Just call it "regclass".
> --- a/evaluate.c
> +++ b/evaluate.c
> @@ -357,7 +357,7 @@ static inline int classify_type(struct symbol
> *type, struct symbol **base)
> return type_class[type->type];
> }
>
> -#define is_int(class) ((class & (TYPE_NUM | TYPE_FLOAT)) == TYPE_NUM)
> +#define is_int(Class) ((Class & (TYPE_NUM | TYPE_FLOAT)) == TYPE_NUM)
"c" or "cls"?
> --- 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 = Typename(token, &sym, NULL);
"type_name"?
> --- a/lib.h
> +++ b/lib.h
> @@ -120,6 +120,10 @@ extern int Wdeclarationafterstatement;
> extern int dbg_entry;
> extern int dbg_dead;
>
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> @@ -162,33 +170,41 @@ static inline void free_instruction_list(struct
> instruction_list **head)
> free_ptr_list((struct ptr_list **)head);
> }
>
> -static inline struct instruction * delete_last_instruction(struct
> instruction_list **head)
> +static inline struct instruction * delete_last_instruction(
> + struct instruction_list **head)
Huh? I don't see a change here, just formatting (and what looks like
whitespace damage).
> {
> - return undo_ptr_list_last((struct ptr_list **)head);
> + return (struct instruction *)undo_ptr_list_last(
> + (struct ptr_list **)head);
> }
Wow. I had to double-check this because I couldn't quite believe C++
had that degree of dain bramage, but sure enough:
/tmp$ cat test.c
extern void *pv(void);
int *pi(void)
{
return pv();
}
/tmp$ gcc -c test.c -o /dev/null
/tmp$ g++ -c test.c -o /dev/null
test.c: In function ‘int* pi()’:
test.c:5: error: invalid conversion from ‘void*’ to ‘int*’
(1) /tmp$
I can understand C++ having stronger typechecking, but void pointers
*exist* for this purpose. *Really* debatable whether Sparse should work
around this. Avoiding keywords, sure, but casting void pointers
everywhere? People *remove* these kinds of casts from C programs as a
cleanup.
- Josh Triplett
--
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
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-11 23:37 ` Josh Triplett
@ 2010-10-12 10:42 ` Bernd Petrovitsch
0 siblings, 0 replies; 41+ messages in thread
From: Bernd Petrovitsch @ 2010-10-12 10:42 UTC (permalink / raw)
To: Josh Triplett; +Cc: Tomas Klacko, Christopher Li, linux-sparse
On Mon, 2010-10-11 at 16:37 -0700, Josh Triplett wrote:
[....]
> Wow. I had to double-check this because I couldn't quite believe C++
> had that degree of dain bramage, but sure enough:
>
> /tmp$ cat test.c
> extern void *pv(void);
>
> int *pi(void)
> {
> return pv();
> }
> /tmp$ gcc -c test.c -o /dev/null
> /tmp$ g++ -c test.c -o /dev/null
> test.c: In function ‘int* pi()’:
> test.c:5: error: invalid conversion from ‘void*’ to ‘int*’
> (1) /tmp$
Welcome to one of the (more obvious) differences between C and C++: you
can't assign/convert/promote a "void *" to any other pointer type (and
vice versa) without explicit type-cast.
For a library written in C, that is the point where "compile it also as
C++" ends IMHO. Just keep the 'extern "C" {' stuff in headers (under
'#ifdef __cplusplus') and compile it as C (and not C++).
BTW there are other similar issues if one digs deep enough.
BTDT (read: looked after a library which was used in 2 "applications" -
one in pure C, the other C++. No way without explicit type-casts which
look somewhat funny and are surely superfluous in C as such).
> I can understand C++ having stronger typechecking, but void pointers
> *exist* for this purpose. *Really* debatable whether Sparse should work
> around this. Avoiding keywords, sure, but casting void pointers
> everywhere? People *remove* these kinds of casts from C programs as a
> cleanup.
Type-casts are inherently evil. But in several situations there is in C
no other (or better) workaround. The above - kill warnings through "void
*" type-casts - makes it worse because some people (including /me) use
the type system in C and want the compiler to check as much as possible.
Bernd
--
mobile: +43 664 4416156 http://www.sysprog.at/
Linux Software Development, Consulting and Services
--
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
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-11 23:01 ` Christopher Li
@ 2010-10-12 22:45 ` Tomas Klacko
2010-10-13 0:37 ` Christopher Li
0 siblings, 1 reply; 41+ messages in thread
From: Tomas Klacko @ 2010-10-12 22:45 UTC (permalink / raw)
To: Christopher Li; +Cc: Al Viro, Josh Triplett, linux-sparse
Hi,
Thanks everyone for your comments, I have refined the patch
and I am posting the next version (below).
On Tue, Oct 12, 2010 at 1:01 AM, Christopher Li <sparse@chrisli.org> wrote:
> On Mon, Oct 11, 2010 at 3:46 PM, Al Viro <viro@zeniv.linux.org.uk> wrote:
>> On Tue, Oct 12, 2010 at 12:33:32AM +0200, Tomas Klacko wrote:
>>
>>> Great. I am posting my current status (as a patch) so that you can comment on it
>>> and that I can refine it further.
>>
>> ehh... Use of capitalized variable names is a Bad Idea(tm). Especially
>> since you are doing that well outside of headers, so even compatibility
>> with Straustrups's Mistake does not serve as a reason.
>
> I am about to complain the same thing. Al beats me to it.
>
> Tomas, can you limit the change on the header file C++ friendly first?
> I don't think the rest of the C code need to be compile in C++, so it is fine
> using C++ key words.
I don't think I quite get your question. I have limited the amount of changes
to the C source files, but there are still some. Which result for instance
from renaming "struct symbol->namespace" to "struct symbol->ns".
However, I can probably try doing:
struct symbol
{
...
#ifndef __cplusplus
enum namespace namespace;
#else
enum name_space ns;
#endif
...
};
and then try to work out any consequences solely in the header files.
After all, using different names for the same types in C++ versus C
should still result in correct code.
Is this what you mean?
This is the patch:
From 173752ef827820d8c6505501b07d2680ec020b48 Mon Sep 17 00:00:00 2001
From: Tomas Klacko <tomas.klacko@gmail.com>
Date: Tue, 12 Oct 2010 00:25:46 +0000
Subject: [PATCH] Make headers usable in Cxx code.
---
c2xml.c | 6 +++---
ctags.c | 6 +++---
expression.c | 12 ++++++------
expression.h | 8 ++++++--
graph.c | 2 +-
lib.h | 34 ++++++++++++++++++++++++++++++++++
linearize.h | 4 ++--
parse.c | 22 +++++++++++-----------
parse.h | 2 ++
pre-process.c | 10 +++++-----
ptrlist.h | 22 ++++++++++++++++++++--
symbol.c | 10 +++++-----
symbol.h | 14 +++++++-------
token.h | 8 ++++++++
14 files changed, 113 insertions(+), 47 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..d85f16c 100644
--- a/expression.h
+++ b/expression.h
@@ -196,13 +196,17 @@ 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) {
+#ifndef __cplusplus
struct symbol *sym = lookup_symbol(token->ident, NS_SYMBOL | NS_TYPEDEF);
- return sym && (sym->namespace & NS_TYPEDEF);
+#else
+ struct symbol *sym = lookup_symbol(token->ident, (enum
name_space)(NS_SYMBOL | NS_TYPEDEF));
+#endif
+ 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..4acd61e 100644
--- a/lib.h
+++ b/lib.h
@@ -120,6 +120,10 @@ extern int Wdeclarationafterstatement;
extern int dbg_entry;
extern int dbg_dead;
+#ifdef __cplusplus
+extern "C" {
+#endif
+
extern void declare_builtin_functions(void);
extern void create_builtin_stream(void);
extern struct symbol_list *sparse_initialize(int argc, char **argv,
struct string_list **files);
@@ -127,6 +131,10 @@ extern struct symbol_list *__sparse(char *filename);
extern struct symbol_list *sparse_keep_tokens(char *filename);
extern struct symbol_list *sparse(char *filename);
+#ifdef __cplusplus
+}
+#endif
+
static inline int symbol_list_size(struct symbol_list *list)
{
return ptr_list_size((struct ptr_list *)(list));
@@ -164,31 +172,57 @@ static inline void free_instruction_list(struct
instruction_list **head)
static inline struct instruction * delete_last_instruction(struct
instruction_list **head)
{
+#ifndef __cplusplus
return undo_ptr_list_last((struct ptr_list **)head);
+#else
+ return (struct instruction *)undo_ptr_list_last((struct ptr_list **)head);
+#endif
}
static inline struct basic_block * delete_last_basic_block(struct
basic_block_list **head)
{
+#ifndef __cplusplus
return delete_ptr_list_last((struct ptr_list **)head);
+#else
+ return (struct basic_block *)delete_ptr_list_last((struct ptr_list **)head);
+
+#endif
}
static inline struct basic_block *first_basic_block(struct
basic_block_list *head)
{
+#ifndef __cplusplus
return first_ptr_list((struct ptr_list *)head);
+#else
+ return (struct basic_block *)first_ptr_list((struct ptr_list *)head);
+
+#endif
}
static inline struct instruction *last_instruction(struct
instruction_list *head)
{
+#ifndef __cplusplus
return last_ptr_list((struct ptr_list *)head);
+#else
+ return (struct instruction *)last_ptr_list((struct ptr_list *)head);
+#endif
}
static inline struct instruction *first_instruction(struct
instruction_list *head)
{
+#ifndef __cplusplus
return first_ptr_list((struct ptr_list *)head);
+#else
+ return (struct instruction *)first_ptr_list((struct ptr_list *)head);
+#endif
}
static inline pseudo_t first_pseudo(struct pseudo_list *head)
{
+#ifndef __cplusplus
return first_ptr_list((struct ptr_list *)head);
+#else
+ return (pseudo_t)first_ptr_list((struct ptr_list *)head);
+#endif
}
static inline void concat_symbol_list(struct symbol_list *from,
struct symbol_list **to)
diff --git a/linearize.h b/linearize.h
index 50b3601..a385968 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 *new_list, int count)
{
- replace_ptr_list_entry((struct ptr_list **)list, old, new, count);
+ replace_ptr_list_entry((struct ptr_list **)list, old, new_list, count);
}
struct entrypoint {
diff --git a/parse.c b/parse.c
index 537055f..29d6e16 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,
+ .cls = 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,
+ .cls = 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,
+ .cls = 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,
+ .cls = 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,
+ .cls = 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->cls;
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..7da875e 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)((void*)&(ptr) == (void*)&(head)->list[0])
+#endif
+
/*
* The "unnecessary" statement expression is there to shut up a totally
* bogus gcc warning about unused expressions, brought on by the fact
@@ -36,10 +42,14 @@ struct ptr_list {
#define ptr_list_empty(x) ((x) == NULL)
+#ifdef __cplusplus
+extern "C" {
+#endif
+
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 *new_list, int);
extern void sort_list(struct ptr_list **, int (*)(const void *, const void *));
extern void **__add_ptr_list(struct ptr_list **, void *, unsigned long);
@@ -48,6 +58,10 @@ extern void __free_ptr_list(struct ptr_list **);
extern int ptr_list_size(struct ptr_list *);
extern int linearize_ptr_list(struct ptr_list *, void **, int);
+#ifdef __cplusplus
+}
+#endif
+
/*
* Hey, who said that you can't do overloading in C?
*
@@ -270,7 +284,11 @@ extern void pack_ptr_list(struct ptr_list **);
static inline void update_tag(void *p, unsigned long tag)
{
+#ifndef __cplusplus
unsigned long *ptr = p;
+#else
+ unsigned long *ptr = (unsigned long *)p;
+#endif
*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..fdb5d2e 100644
--- a/symbol.h
+++ b/symbol.h
@@ -24,7 +24,7 @@
* token contains the information on where the symbol was
* declared.
*/
-enum namespace {
+enum name_space {
NS_NONE = 0,
NS_MACRO = 1,
NS_TYPEDEF = 2,
@@ -109,7 +109,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, cls;
};
extern int expand_safe_p(struct expression *expr, int cost);
@@ -121,7 +121,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 +267,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 +279,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 +367,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..7d17296 100644
--- a/token.h
+++ b/token.h
@@ -175,7 +175,11 @@ struct token {
static inline struct token *containing_token(struct token **p)
{
void *addr = (char *)p - ((char *)&((struct token *)0)->next - (char *)0);
+#ifndef __cplusplus
return addr;
+#else
+ return (struct token*)addr;
+#endif
}
#define token_type(x) ((x)->pos.type)
@@ -205,7 +209,11 @@ extern struct token *preprocess(struct token *);
static inline int match_op(struct token *token, int op)
{
+#ifndef __cplusplus
return token->pos.type == TOKEN_SPECIAL && token->special == op;
+#else
+ return token->pos.type == TOKEN_SPECIAL && token->special == (unsigned int)op;
+#endif
}
static inline int match_ident(struct token *token, struct ident *id)
--
1.5.4.3
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
^ permalink raw reply related [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
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
0 siblings, 2 replies; 41+ messages in thread
From: Christopher Li @ 2010-10-13 0:37 UTC (permalink / raw)
To: Tomas Klacko; +Cc: Al Viro, Josh Triplett, linux-sparse
On Tue, Oct 12, 2010 at 3:45 PM, Tomas Klacko <tomas.klacko@gmail.com> wrote:
> Hi,
>
> Thanks everyone for your comments, I have refined the patch
> and I am posting the next version (below).
>
> On Tue, Oct 12, 2010 at 1:01 AM, Christopher Li <sparse@chrisli.org> wrote:
>> On Mon, Oct 11, 2010 at 3:46 PM, Al Viro <viro@zeniv.linux.org.uk> wrote:
>>> On Tue, Oct 12, 2010 at 12:33:32AM +0200, Tomas Klacko wrote:
>>>
>>
>> I am about to complain the same thing. Al beats me to it.
>>
>> Tomas, can you limit the change on the header file C++ friendly first?
>> I don't think the rest of the C code need to be compile in C++, so it is fine
>> using C++ key words.
>
> I don't think I quite get your question. I have limited the amount of changes
> to the C source files, but there are still some. Which result for instance
> from renaming "struct symbol->namespace" to "struct symbol->ns".
Rename header members to avoid keyword are fine. You don't need to change
any thing that is internal of a C code. e.g. from your previous patch:
<quote>
-static struct storage *get_reg(struct regclass *class)
+static struct storage *get_reg(struct regclass *Class)
</quote>
This function is outside of header file.
> However, I can probably try doing:
> struct symbol
> {
> ...
> #ifndef __cplusplus
> enum namespace namespace;
> #else
> enum name_space ns;
> #endif
Even worse.
I don't like the #ifndef __cplusplus at all. Try to keep it minimal.
Just make it "enum name_space ns;" is clear better than maintain two
different names.
> and then try to work out any consequences solely in the header files.
> After all, using different names for the same types in C++ versus C
> should still result in correct code.
That is evil.
> if (token->pos.type == TOKEN_IDENT) {
> +#ifndef __cplusplus
> struct symbol *sym = lookup_symbol(token->ident, NS_SYMBOL | NS_TYPEDEF);
> - return sym && (sym->namespace & NS_TYPEDEF);
> +#else
> + struct symbol *sym = lookup_symbol(token->ident, (enum
> name_space)(NS_SYMBOL | NS_TYPEDEF));
> +#endif
Hmm, NS_SYMBOL | NS_TYPEDEF looks better.
Maybe declare NS_SYMBOL_OR_TYPEDEF = NS_SYMBOL | NS_TYPEDEF as
one of the enum name_space so we don't need to force cast here.
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
Can you move this into your C++ code before including the sparse headers?
I don't want it in the sparse headers. Sparse is compiled in C,
shouldn't need to know
C++ at all.
>- .class = CChar,
>+ .cls = CChar,
"klass" instead of "cls" ?
>
> +#ifdef __cplusplus
> +}
> +#endif
> +
And this too.
> {
> +#ifndef __cplusplus
> return undo_ptr_list_last((struct ptr_list **)head);
> +#else
> + return (struct instruction *)undo_ptr_list_last((struct ptr_list **)head);
> +#endif
Just keep the else branch and remove the #ifndef. It is harmless to do
a type cast
in C here. Same for the following inline functions.
> static inline void concat_symbol_list(struct symbol_list *from,
> struct symbol_list **to)
> diff --git a/linearize.h b/linearize.h
> index 50b3601..a385968 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 *new_list, int count)
> {
> - replace_ptr_list_entry((struct ptr_list **)list, old, new, count);
> + replace_ptr_list_entry((struct ptr_list **)list, old, new_list, count);
new_list -> newlist
> 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?
> /* 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.
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
Get rid of this too.
> static inline void update_tag(void *p, unsigned long tag)
> {
> +#ifndef __cplusplus
> unsigned long *ptr = p;
> +#else
> + unsigned long *ptr = (unsigned long *)p;
> +#endif
> *ptr = tag | (~3UL & *ptr);
> }
Just keep the #else branch and get rid of the #ifndef
> +++ b/token.h
> @@ -175,7 +175,11 @@ struct token {
> static inline struct token *containing_token(struct token **p)
> {
> void *addr = (char *)p - ((char *)&((struct token *)0)->next - (char *)0);
> +#ifndef __cplusplus
> return addr;
> +#else
> + return (struct token*)addr;
> +#endif
Same here.
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
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-13 0:37 ` Christopher Li
@ 2010-10-13 11:39 ` Bernd Petrovitsch
2010-10-16 16:03 ` Tomas Klacko
1 sibling, 0 replies; 41+ messages in thread
From: Bernd Petrovitsch @ 2010-10-13 11:39 UTC (permalink / raw)
To: Christopher Li; +Cc: Tomas Klacko, Al Viro, Josh Triplett, linux-sparse
On Die, 2010-10-12 at 17:37 -0700, Christopher Li wrote:
[...]
> > However, I can probably try doing:
> > struct symbol
> > {
> > ...
> > #ifndef __cplusplus
> > enum namespace namespace;
> > #else
> > enum name_space ns;
> > #endif
>
> Even worse.
FullACK. That's IMHO the worst solution - sprinkling "#ifndef
__cplusplus" all over the place.
> I don't like the #ifndef __cplusplus at all. Try to keep it minimal.
> Just make it "enum name_space ns;" is clear better than maintain two
> different names.
*eg*
---- snip ----
#ifdef __cplusplus
#define namespace ns
#endif
---- snip ----
at the top would be simpler and keep the source readable. Nevertheless I
wouldn't do it either.
[...]
> > +#ifdef __cplusplus
> > +extern "C" {
> > +#endif
>
> Can you move this into your C++ code before including the sparse headers?
> I don't want it in the sparse headers. Sparse is compiled in C,
> shouldn't need to know
> C++ at all.
That is something common in .h files if they are intended for "mixed
use" and C libs use in C++ applications.
[...]
> > +#ifdef __cplusplus
> > +}
> > +#endif
> > +
[...]
Bernd
--
Bernd Petrovitsch Email : bernd@petrovitsch.priv.at
LUGA : http://www.luga.at
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
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
0 siblings, 2 replies; 41+ messages in thread
From: Bernd Petrovitsch @ 2010-10-13 14:45 UTC (permalink / raw)
To: Christopher Li; +Cc: Kamil Dudka, Tomas Klacko, linux-sparse, Josh Triplett
[-- Attachment #1: Type: text/plain, Size: 1946 bytes --]
On Mon, 2010-10-11 at 12:12 -0700, Josh Triplett wrote:
[...]
> Actually, Sparse seems to use "true" and "false" as variable names in
> several cases; for instance:
>
> static struct symbol *evaluate_conditional_expression(struct expression *expr)
> {
> struct expression **true;
> [...]
> true = &expr->conditional;
>
>
> I think this only works because evaluate.c doesn't include stdbool.h.
> And sure enough, if I include stdbool.h from evaluate.c:
>
> CC evaluate.o
> evaluate.c: In function ‘evaluate_conditional_expression’:
> evaluate.c:1081: error: expected identifier or ‘(’ before numeric constant
> evaluate.c:1095: error: lvalue required as left operand of assignment
> evaluate.c:1101: error: lvalue required as left operand of assignment
> evaluate.c:1106: error: invalid type argument of ‘unary *’ (have ‘int’)
> evaluate.c:1114: error: invalid type argument of ‘unary *’ (have ‘int’)
> evaluate.c:1116: error: invalid type argument of ‘unary *’ (have ‘int’)
> evaluate.c:1116: error: invalid type argument of ‘unary *’ (have ‘int’)
> evaluate.c:1122: error: invalid type argument of ‘unary *’ (have ‘int’)
> evaluate.c:1126: error: invalid type argument of ‘unary *’ (have ‘int’)
> evaluate.c:1126: error: invalid type argument of ‘unary *’ (have ‘int’)
> evaluate.c:1133: error: invalid type argument of ‘unary *’ (have ‘int’)
> evaluate.c:1134: error: invalid type argument of ‘unary *’ (have ‘int’)
> evaluate.c:1134: error: invalid type argument of ‘unary *’ (have ‘int’)
> evaluate.c:1202: error: invalid type argument of ‘unary *’ (have ‘int’)
> evaluate.c:1202: error: invalid type argument of ‘unary *’ (have ‘int’)
FWIW, the attached patch should fix that.
Bernd
--
Bernd Petrovitsch Email : bernd@petrovitsch.priv.at
LUGA : http://www.luga.at
[-- Attachment #2: 0001-avoid-the-use-of-true-and-false-as-variable-names.patch --]
[-- Type: text/x-patch, Size: 14085 bytes --]
rename the local variables "true" and "false" to "if_true" and "if_false",
respectively to not clash with the well-known "keywords" defined by C99.
This is similar to commit 0be55c9.
Signed-off-by: Bernd Petrovitsch <bernd@sysprog.at>
---
compile-i386.c | 18 +++++++++---------
evaluate.c | 22 +++++++++++-----------
expand.c | 18 +++++++++---------
flow.c | 18 +++++++++---------
inline.c | 26 +++++++++++++-------------
linearize.c | 12 ++++++------
pre-process.c | 4 ++--
show-parse.c | 6 +++---
simplify.c | 16 ++++++++--------
9 files changed, 70 insertions(+), 70 deletions(-)
diff --git a/compile-i386.c b/compile-i386.c
index abe9313..0770147 100644
--- a/compile-i386.c
+++ b/compile-i386.c
@@ -1542,7 +1542,7 @@ static struct storage *emit_return_stmt(struct statement *stmt)
static struct storage *emit_conditional_expr(struct expression *expr)
{
- struct storage *cond, *true = NULL, *false = NULL;
+ struct storage *cond, *if_true = NULL, *if_false = NULL;
struct storage *new = stack_alloc(expr->ctype->bit_size / 8);
int target_false, cond_end;
@@ -1551,16 +1551,16 @@ static struct storage *emit_conditional_expr(struct expression *expr)
target_false = emit_conditional_test(cond);
/* handle if-true part of the expression */
- true = x86_expression(expr->cond_true);
+ if_true = x86_expression(expr->cond_true);
- emit_copy(new, true, expr->ctype);
+ emit_copy(new, if_true, expr->ctype);
cond_end = emit_conditional_end(target_false);
/* handle if-false part of the expression */
- false = x86_expression(expr->cond_false);
+ if_false = x86_expression(expr->cond_false);
- emit_copy(new, false, expr->ctype);
+ emit_copy(new, if_false, expr->ctype);
/* end of conditional; jump target for if-true branch */
emit_label(cond_end, "end conditional");
@@ -1571,15 +1571,15 @@ static struct storage *emit_conditional_expr(struct expression *expr)
static struct storage *emit_select_expr(struct expression *expr)
{
struct storage *cond = x86_expression(expr->conditional);
- struct storage *true = x86_expression(expr->cond_true);
- struct storage *false = x86_expression(expr->cond_false);
+ struct storage *if_true = x86_expression(expr->cond_true);
+ struct storage *if_false = x86_expression(expr->cond_false);
struct storage *reg_cond, *reg_true, *reg_false;
struct storage *new = stack_alloc(4);
emit_comment("begin SELECT");
reg_cond = get_reg_value(cond, get_regclass(expr->conditional));
- reg_true = get_reg_value(true, get_regclass(expr));
- reg_false = get_reg_value(false, get_regclass(expr));
+ reg_true = get_reg_value(if_true, get_regclass(expr));
+ reg_false = get_reg_value(if_false, get_regclass(expr));
/*
* Do the actual select: check the conditional for zero,
diff --git a/evaluate.c b/evaluate.c
index f8343c2..e243be5 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -1077,7 +1077,7 @@ OK:
*/
static struct symbol *evaluate_conditional_expression(struct expression *expr)
{
- struct expression **true;
+ struct expression **if_true;
struct symbol *ctype, *ltype, *rtype, *lbase, *rbase;
int lclass, rclass;
const char * typediff;
@@ -1091,18 +1091,18 @@ static struct symbol *evaluate_conditional_expression(struct expression *expr)
ctype = degenerate(expr->conditional);
rtype = degenerate(expr->cond_false);
- true = &expr->conditional;
+ if_true = &expr->conditional;
ltype = ctype;
if (expr->cond_true) {
if (!evaluate_expression(expr->cond_true))
return NULL;
ltype = degenerate(expr->cond_true);
- true = &expr->cond_true;
+ if_true = &expr->cond_true;
}
if (expr->flags) {
int flags = expr->conditional->flags & Int_const_expr;
- flags &= (*true)->flags & expr->cond_false->flags;
+ flags &= (*if_true)->flags & expr->cond_false->flags;
if (!flags)
expr->flags = 0;
}
@@ -1110,27 +1110,27 @@ static struct symbol *evaluate_conditional_expression(struct expression *expr)
lclass = classify_type(ltype, <ype);
rclass = classify_type(rtype, &rtype);
if (lclass & rclass & TYPE_NUM) {
- ctype = usual_conversions('?', *true, expr->cond_false,
+ ctype = usual_conversions('?', *if_true, expr->cond_false,
lclass, rclass, ltype, rtype);
- *true = cast_to(*true, ctype);
+ *if_true = cast_to(*if_true, ctype);
expr->cond_false = cast_to(expr->cond_false, ctype);
goto out;
}
if ((lclass | rclass) & TYPE_PTR) {
- int is_null1 = is_null_pointer_constant(*true);
+ int is_null1 = is_null_pointer_constant(*if_true);
int is_null2 = is_null_pointer_constant(expr->cond_false);
if (is_null1 && is_null2) {
- *true = cast_to(*true, &ptr_ctype);
+ *if_true = cast_to(*if_true, &ptr_ctype);
expr->cond_false = cast_to(expr->cond_false, &ptr_ctype);
ctype = &ptr_ctype;
goto out;
}
if (is_null1 && (rclass & TYPE_PTR)) {
if (is_null1 == 2)
- bad_null(*true);
- *true = cast_to(*true, rtype);
+ bad_null(*if_true);
+ *if_true = cast_to(*if_true, rtype);
ctype = rtype;
goto out;
}
@@ -1198,7 +1198,7 @@ Qual:
sym->ctype.modifiers |= qual;
ctype = sym;
}
- *true = cast_to(*true, ctype);
+ *if_true = cast_to(*if_true, ctype);
expr->cond_false = cast_to(expr->cond_false, ctype);
goto out;
}
diff --git a/expand.c b/expand.c
index b965dc3..8d7de3e 100644
--- a/expand.c
+++ b/expand.c
@@ -508,27 +508,27 @@ static int expand_compare(struct expression *expr)
static int expand_conditional(struct expression *expr)
{
struct expression *cond = expr->conditional;
- struct expression *true = expr->cond_true;
- struct expression *false = expr->cond_false;
+ struct expression *if_true = expr->cond_true;
+ struct expression *if_false = expr->cond_false;
int cost, cond_cost;
cond_cost = expand_expression(cond);
if (cond->type == EXPR_VALUE) {
unsigned flags = expr->flags;
if (!cond->value)
- true = false;
- if (!true)
- true = cond;
- cost = expand_expression(true);
- *expr = *true;
+ if_true = if_false;
+ if (!if_true)
+ if_true = cond;
+ cost = expand_expression(if_true);
+ *expr = *if_true;
expr->flags = flags;
if (expr->type == EXPR_VALUE)
expr->taint |= cond->taint;
return cost;
}
- cost = expand_expression(true);
- cost += expand_expression(false);
+ cost = expand_expression(if_true);
+ cost += expand_expression(if_false);
if (cost < SELECT_COST) {
expr->type = EXPR_SELECT;
diff --git a/flow.c b/flow.c
index 5bd9a1d..1df8646 100644
--- a/flow.c
+++ b/flow.c
@@ -100,7 +100,7 @@ static int try_to_simplify_bb(struct basic_block *bb, struct instruction *first,
struct basic_block *source, *target;
pseudo_t pseudo;
struct instruction *br;
- int true;
+ int if_true;
if (!def)
continue;
@@ -113,10 +113,10 @@ static int try_to_simplify_bb(struct basic_block *bb, struct instruction *first,
continue;
if (br->opcode != OP_BR)
continue;
- true = pseudo_truth_value(pseudo);
- if (true < 0)
+ if_true = pseudo_truth_value(pseudo);
+ if (if_true < 0)
continue;
- target = true ? second->bb_true : second->bb_false;
+ target = if_true ? second->bb_true : second->bb_false;
if (bb_depends_on(target, bb))
continue;
changed |= rewrite_branch(source, &br->bb_true, bb, target);
@@ -165,7 +165,7 @@ static int simplify_phi_branch(struct basic_block *bb, struct instruction *br)
}
static int simplify_branch_branch(struct basic_block *bb, struct instruction *br,
- struct basic_block **target_p, int true)
+ struct basic_block **target_p, int if_true)
{
struct basic_block *target = *target_p, *final;
struct instruction *insn;
@@ -181,7 +181,7 @@ static int simplify_branch_branch(struct basic_block *bb, struct instruction *br
* Now we just need to see if we can rewrite the branch..
*/
retval = 0;
- final = true ? insn->bb_true : insn->bb_false;
+ final = if_true ? insn->bb_true : insn->bb_false;
if (bb_has_side_effects(target))
goto try_to_rewrite_target;
if (bb_depends_on(final, target))
@@ -823,13 +823,13 @@ static struct basic_block * rewrite_branch_bb(struct basic_block *bb, struct ins
{
struct basic_block *parent;
struct basic_block *target = br->bb_true;
- struct basic_block *false = br->bb_false;
+ struct basic_block *if_false = br->bb_false;
- if (target && false) {
+ if (target && if_false) {
pseudo_t cond = br->cond;
if (cond->type != PSEUDO_VAL)
return NULL;
- target = cond->value ? target : false;
+ target = cond->value ? target : if_false;
}
/*
diff --git a/inline.c b/inline.c
index 860c0ee..612b843 100644
--- a/inline.c
+++ b/inline.c
@@ -162,14 +162,14 @@ static struct expression * copy_expression(struct expression *expr)
case EXPR_SELECT:
case EXPR_CONDITIONAL: {
struct expression *cond = copy_expression(expr->conditional);
- struct expression *true = copy_expression(expr->cond_true);
- struct expression *false = copy_expression(expr->cond_false);
- if (cond == expr->conditional && true == expr->cond_true && false == expr->cond_false)
+ struct expression *if_true = copy_expression(expr->cond_true);
+ struct expression *if_false = copy_expression(expr->cond_false);
+ if (cond == expr->conditional && if_true == expr->cond_true && if_false == expr->cond_false)
break;
expr = dup_expression(expr);
expr->conditional = cond;
- expr->cond_true = true;
- expr->cond_false = false;
+ expr->cond_true = if_true;
+ expr->cond_false = if_false;
break;
}
@@ -353,20 +353,20 @@ static struct statement *copy_one_statement(struct statement *stmt)
}
case STMT_IF: {
struct expression *cond = stmt->if_conditional;
- struct statement *true = stmt->if_true;
- struct statement *false = stmt->if_false;
+ struct statement *if_true = stmt->if_true;
+ struct statement *if_false = stmt->if_false;
cond = copy_expression(cond);
- true = copy_one_statement(true);
- false = copy_one_statement(false);
+ if_true = copy_one_statement(if_true);
+ if_false = copy_one_statement(if_false);
if (stmt->if_conditional == cond &&
- stmt->if_true == true &&
- stmt->if_false == false)
+ stmt->if_true == if_true &&
+ stmt->if_false == if_false)
break;
stmt = dup_statement(stmt);
stmt->if_conditional = cond;
- stmt->if_true = true;
- stmt->if_false = false;
+ stmt->if_true = if_true;
+ stmt->if_false = if_false;
break;
}
case STMT_RETURN: {
diff --git a/linearize.c b/linearize.c
index f2034ce..d29efce 100644
--- a/linearize.c
+++ b/linearize.c
@@ -1287,19 +1287,19 @@ pseudo_t linearize_cond_branch(struct entrypoint *ep, struct expression *expr, s
static pseudo_t linearize_select(struct entrypoint *ep, struct expression *expr)
{
- pseudo_t cond, true, false, res;
+ pseudo_t cond, if_true, if_false, res;
struct instruction *insn;
- true = linearize_expression(ep, expr->cond_true);
- false = linearize_expression(ep, expr->cond_false);
+ if_true = linearize_expression(ep, expr->cond_true);
+ if_false = linearize_expression(ep, expr->cond_false);
cond = linearize_expression(ep, expr->conditional);
insn = alloc_typed_instruction(OP_SEL, expr->ctype);
if (!expr->cond_true)
- true = cond;
+ if_true = cond;
use_pseudo(insn, cond, &insn->src1);
- use_pseudo(insn, true, &insn->src2);
- use_pseudo(insn, false, &insn->src3);
+ use_pseudo(insn, if_true, &insn->src2);
+ use_pseudo(insn, if_false, &insn->src3);
res = alloc_pseudo(insn);
insn->target = res;
diff --git a/pre-process.c b/pre-process.c
index 656acaa..7317d57 100644
--- a/pre-process.c
+++ b/pre-process.c
@@ -1236,13 +1236,13 @@ static int handle_strong_undef(struct stream *stream, struct token **line, struc
return do_handle_undef(stream, line, token, SYM_ATTR_STRONG);
}
-static int preprocessor_if(struct stream *stream, struct token *token, int true)
+static int preprocessor_if(struct stream *stream, struct token *token, int if_true)
{
token_type(token) = false_nesting ? TOKEN_SKIP_GROUPS : TOKEN_IF;
free_preprocessor_line(token->next);
token->next = stream->top_if;
stream->top_if = token;
- if (false_nesting || true != 1)
+ if (false_nesting || if_true != 1)
false_nesting++;
return 0;
}
diff --git a/show-parse.c b/show-parse.c
index c97debe..d47d832 100644
--- a/show-parse.c
+++ b/show-parse.c
@@ -1001,11 +1001,11 @@ static int show_label_expr(struct expression *expr)
static int show_conditional_expr(struct expression *expr)
{
int cond = show_expression(expr->conditional);
- int true = show_expression(expr->cond_true);
- int false = show_expression(expr->cond_false);
+ int if_true = show_expression(expr->cond_true);
+ int if_false = show_expression(expr->cond_false);
int new = new_pseudo();
- printf("[v%d]\tcmov.%d\t\tv%d,v%d,v%d\n", cond, expr->ctype->bit_size, new, true, false);
+ printf("[v%d]\tcmov.%d\t\tv%d,v%d,v%d\n", cond, expr->ctype->bit_size, new, if_true, if_false);
return new;
}
diff --git a/simplify.c b/simplify.c
index 8200584..2d70743 100644
--- a/simplify.c
+++ b/simplify.c
@@ -780,10 +780,10 @@ static int simplify_cond_branch(struct instruction *br, pseudo_t cond, struct in
use_pseudo(br, *pp, &br->cond);
remove_usage(cond, &br->cond);
if (def->opcode == OP_SET_EQ) {
- struct basic_block *true = br->bb_true;
- struct basic_block *false = br->bb_false;
- br->bb_false = true;
- br->bb_true = false;
+ struct basic_block *if_true = br->bb_true;
+ struct basic_block *if_false = br->bb_false;
+ br->bb_false = if_true;
+ br->bb_true = if_false;
}
return REPEAT_CSE;
}
@@ -836,10 +836,10 @@ static int simplify_branch(struct instruction *insn)
return REPEAT_CSE;
}
if (val2) {
- struct basic_block *true = insn->bb_true;
- struct basic_block *false = insn->bb_false;
- insn->bb_false = true;
- insn->bb_true = false;
+ struct basic_block *if_true = insn->bb_true;
+ struct basic_block *if_false = insn->bb_false;
+ insn->bb_false = if_true;
+ insn->bb_true = if_false;
}
use_pseudo(insn, def->src1, &insn->cond);
remove_usage(cond, &insn->cond);
--
1.7.2.3
^ permalink raw reply related [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-13 0:37 ` Christopher Li
2010-10-13 11:39 ` Bernd Petrovitsch
@ 2010-10-16 16:03 ` Tomas Klacko
2010-10-16 19:11 ` Josh Triplett
1 sibling, 1 reply; 41+ messages in thread
From: Tomas Klacko @ 2010-10-16 16:03 UTC (permalink / raw)
To: Christopher Li; +Cc: Al Viro, Josh Triplett, linux-sparse
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
^ permalink raw reply related [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-16 16:03 ` Tomas Klacko
@ 2010-10-16 19:11 ` Josh Triplett
2010-10-17 10:31 ` Tomas Klacko
2010-10-18 3:16 ` Christopher Li
0 siblings, 2 replies; 41+ messages in thread
From: Josh Triplett @ 2010-10-16 19:11 UTC (permalink / raw)
To: Tomas Klacko; +Cc: Christopher Li, Al Viro, linux-sparse
On Sat, Oct 16, 2010 at 06:03:53PM +0200, Tomas Klacko wrote:
> 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’
Huh, interesting. Turns out that giant union contains two different
structs of the form { struct symbol *, struct statement * }; one for
label_arg and one for labeled_struct. They have different names for the
symbol, but the same name for the statement. We should fix that for C
as well, either by renaming one of the statements, or by just making
both variations use the same set of fields and dropping one of the
sub-structs. Either way, that should happen as an independent patch,
separate from the C++ compatibility changes.
Chris, what do you think?
> >> /* 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)
> ?
As far as I can tell, CHECK_TYPE works just fine in C++. I could easily
compile an invocation of CHECK_TYPE, as well as some simple examples
that called the macros which invoked CHECK_TYPE. When I tried
FOR_EACH_PTR, I encountered *other* warnings (related to assigning (void
*) to some other type without a cast), but those warnings didn't come
from CHECK_TYPE.
What warning do you encounter about CHECK_TYPE?
- Josh Triplett
--
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
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
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 3:16 ` Christopher Li
1 sibling, 2 replies; 41+ messages in thread
From: Tomas Klacko @ 2010-10-17 10:31 UTC (permalink / raw)
To: Josh Triplett; +Cc: Christopher Li, Al Viro, linux-sparse
On Sat, Oct 16, 2010 at 9:11 PM, Josh Triplett <josh@joshtriplett.org> wrote:
> On Sat, Oct 16, 2010 at 06:03:53PM +0200, Tomas Klacko wrote:
>> 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:
>> >> /* 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)
>> ?
>
> As far as I can tell, CHECK_TYPE works just fine in C++. I could easily
> compile an invocation of CHECK_TYPE, as well as some simple examples
> that called the macros which invoked CHECK_TYPE. When I tried
> FOR_EACH_PTR, I encountered *other* warnings (related to assigning (void
> *) to some other type without a cast), but those warnings didn't come
> from CHECK_TYPE.
Maybe I did not investigate deeply enough to find out the origin of
the warnings.
But I get no warnings/errors, when I disable CHECK_TYPE in C++ code.
> What warning do you encounter about CHECK_TYPE?
In the following code1 (file main.cc):
int main(int argc, char* argv[])
{
struct string_list *files=NULL;
void* file_void;
char* file_char;
struct symbol_list *symbols=NULL;
struct symbol_list *all_symbols=NULL;
symbols=sparse_initialize(argc, argv, &files);
concat_symbol_list(symbols, &all_symbols);
FOR_EACH_PTR_NOTAG(files, file_void) { // line 19
file_char=(char*)file_void;
symbols=sparse(file_char);
concat_symbol_list(symbols, &all_symbols);
} END_FOR_EACH_PTR_NOTAG(file_void);
exit(EXIT_SUCCESS);
}
I get:
main.cc: In function ‘int main(int, char**)’:
main.cc:19: error: comparison between distinct pointer types ‘void*’
and ‘char*’ lacks a cast
compiler and (important) flags:
g++ (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4), -Wall -Werror
Now, the code2 (file main.cc):
int main(int argc, char* argv[])
{
struct string_list *files=NULL;
char* file_char;
struct symbol_list *symbols=NULL;
struct symbol_list *all_symbols=NULL;
symbols=sparse_initialize(argc, argv, &files);
concat_symbol_list(symbols, &all_symbols);
FOR_EACH_PTR_NOTAG(files, file_char) { // line 18
symbols=sparse(file_char);
concat_symbol_list(symbols, &all_symbols);
} END_FOR_EACH_PTR_NOTAG(file_char);
exit(EXIT_SUCCESS);
}
I get error:
main.cc: In function ‘int main(int, char**)’:
main.cc:18: error: invalid conversion from ‘void*’ to ‘char*’
sparse headers included (in both code examples):
#ifdef __cplusplus
extern "C" {
#endif
#include <sparse/allocate.h>
#include <sparse/expression.h>
#include <sparse/lib.h>
#include <sparse/linearize.h>
#include <sparse/token.h>
#include <sparse/parse.h>
#include <sparse/symbol.h>
#ifdef __cplusplus
}
#endif
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
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-16 19:11 ` Josh Triplett
2010-10-17 10:31 ` Tomas Klacko
@ 2010-10-18 3:16 ` Christopher Li
1 sibling, 0 replies; 41+ messages in thread
From: Christopher Li @ 2010-10-18 3:16 UTC (permalink / raw)
To: Josh Triplett; +Cc: Tomas Klacko, Al Viro, linux-sparse
On Sat, Oct 16, 2010 at 12:11 PM, Josh Triplett <josh@joshtriplett.org> wrote:
> Huh, interesting. Turns out that giant union contains two different
> structs of the form { struct symbol *, struct statement * }; one for
> label_arg and one for labeled_struct. They have different names for the
> symbol, but the same name for the statement. We should fix that for C
> as well, either by renaming one of the statements, or by just making
> both variations use the same set of fields and dropping one of the
> sub-structs. Either way, that should happen as an independent patch,
> separate from the C++ compatibility changes.
That make sense. It seems to me that label_arg is not actually used.
It might used in very early code. The member statement->label is never
referenced now. There is no point to keep it as far as I can tell.
Just remove that label_arg union and sparse compile just fine.
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
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-17 10:31 ` Tomas Klacko
@ 2010-10-18 4:13 ` Christopher Li
2010-10-18 5:39 ` Josh Triplett
1 sibling, 0 replies; 41+ messages in thread
From: Christopher Li @ 2010-10-18 4:13 UTC (permalink / raw)
To: Tomas Klacko; +Cc: Josh Triplett, Al Viro, linux-sparse
On Sun, Oct 17, 2010 at 3:31 AM, Tomas Klacko <tomas.klacko@gmail.com> wrote:
>> What warning do you encounter about CHECK_TYPE?
> I get:
> main.cc: In function ‘int main(int, char**)’:
> main.cc:19: error: comparison between distinct pointer types ‘void*’
> and ‘char*’ lacks a cast
>
> compiler and (important) flags:
> g++ (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4), -Wall -Werror
>
>
> Now, the code2 (file main.cc):
> I get error:
> main.cc: In function ‘int main(int, char**)’:
> main.cc:18: error: invalid conversion from ‘void*’ to ‘char*’
That sounds like some thing need to be fixed before the patch can go in.
I give this C++ changes more thought. The sparse code is written in
pure C. I don't
want to make C++ as another burden of sparse developers. The
alternative always exist,
which is compiling your sparse related code in C then link to your C++ program.
Here is my guide line for the C++ related changes.
The change needs to make sense in C alone. That means no "#ifdef __cplusplus".
Sparse itself is pure C.I am not a C++ expert, I really don't know
what is going on
inside the C++ portion of the code. It is pure burden for most sparse
developers who
don't deal with C++, me included.
Personally I don't care about including sparse header in C++. But that
being said,
I am willing to make some compromise. e.g. the keyword renaming adds no value
for the C code, if that is all it takes to make C++ happy, fine.
The rest still need to make sense in C. E.g. removing the dead label_arg union
is a good change by itself.
Fundamentally the C++ and C99 are not compatible. So there is a limit
you can push
for including C code in C++. Sparse uses a lot of C specific code in
the header file.
For the nasty case, it seems that using the alternative method is not too bad.
It is inconvenient, but only limit to very few users.
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
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
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
1 sibling, 1 reply; 41+ messages in thread
From: Josh Triplett @ 2010-10-18 5:39 UTC (permalink / raw)
To: Tomas Klacko; +Cc: Christopher Li, Al Viro, linux-sparse
On Sun, Oct 17, 2010 at 12:31:26PM +0200, Tomas Klacko wrote:
> On Sat, Oct 16, 2010 at 9:11 PM, Josh Triplett <josh@joshtriplett.org> wrote:
> > On Sat, Oct 16, 2010 at 06:03:53PM +0200, Tomas Klacko wrote:
> >> 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:
>
> >> >> /* 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)
> >> ?
> >
> > As far as I can tell, CHECK_TYPE works just fine in C++. I could easily
> > compile an invocation of CHECK_TYPE, as well as some simple examples
> > that called the macros which invoked CHECK_TYPE. When I tried
> > FOR_EACH_PTR, I encountered *other* warnings (related to assigning (void
> > *) to some other type without a cast), but those warnings didn't come
> > from CHECK_TYPE.
>
> Maybe I did not investigate deeply enough to find out the origin of
> the warnings.
> But I get no warnings/errors, when I disable CHECK_TYPE in C++ code.
>
> > What warning do you encounter about CHECK_TYPE?
>
> In the following code1 (file main.cc):
> int main(int argc, char* argv[])
> {
> struct string_list *files=NULL;
>
> void* file_void;
> char* file_char;
>
> struct symbol_list *symbols=NULL;
> struct symbol_list *all_symbols=NULL;
>
> symbols=sparse_initialize(argc, argv, &files);
> concat_symbol_list(symbols, &all_symbols);
>
> FOR_EACH_PTR_NOTAG(files, file_void) { // line 19
> file_char=(char*)file_void;
> symbols=sparse(file_char);
> concat_symbol_list(symbols, &all_symbols);
> } END_FOR_EACH_PTR_NOTAG(file_void);
>
> exit(EXIT_SUCCESS);
> }
>
> I get:
> main.cc: In function ‘int main(int, char**)’:
> main.cc:19: error: comparison between distinct pointer types ‘void*’
> and ‘char*’ lacks a cast
This warning means that CHECK_TYPE has done its job correctly; you
should not use the void * file_void to iterate over a list of files.
FOR_EACH_PTR (and the _NOTAG variant) expect a list type and the
corresponding element type, and they use CHECK_TYPE to make this
type-safe.
> compiler and (important) flags:
> g++ (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu4), -Wall -Werror
>
>
> Now, the code2 (file main.cc):
> int main(int argc, char* argv[])
> {
> struct string_list *files=NULL;
>
> char* file_char;
>
> struct symbol_list *symbols=NULL;
> struct symbol_list *all_symbols=NULL;
>
> symbols=sparse_initialize(argc, argv, &files);
> concat_symbol_list(symbols, &all_symbols);
>
> FOR_EACH_PTR_NOTAG(files, file_char) { // line 18
> symbols=sparse(file_char);
> concat_symbol_list(symbols, &all_symbols);
> } END_FOR_EACH_PTR_NOTAG(file_char);
>
> exit(EXIT_SUCCESS);
> }
>
> I get error:
> main.cc: In function ‘int main(int, char**)’:
> main.cc:18: error: invalid conversion from ‘void*’ to ‘char*’
This warning doesn't come from CHECK_TYPE; it comes from the subsequent
implicit conversion from the list's void * to the desired type char *,
which will indeed need a cast to work correctly when included from C++.
Based on these two code examples, I think you don't need to change
CHECK_TYPE at all. (And the user should always use code like your
second example, not your first example.)
(Of course, if someone really wants to use these lists from C++, they
might want to build appropriate type-safe C++ iterator types on top of
the ptrlist bits. :) )
- Josh Triplett
--
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
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-18 5:39 ` Josh Triplett
@ 2010-10-18 18:37 ` Christopher Li
2010-10-19 20:03 ` Tomas Klacko
0 siblings, 1 reply; 41+ messages in thread
From: Christopher Li @ 2010-10-18 18:37 UTC (permalink / raw)
To: Josh Triplett; +Cc: Tomas Klacko, Al Viro, linux-sparse
On Sun, Oct 17, 2010 at 10:39 PM, Josh Triplett <josh@joshtriplett.org> wrote:
>
> Based on these two code examples, I think you don't need to change
> CHECK_TYPE at all. (And the user should always use code like your
> second example, not your first example.)
Oh good, then we can completely remove the #ifdef __cplusplus.
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
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-13 14:45 ` Bernd Petrovitsch
@ 2010-10-18 18:43 ` Christopher Li
2010-10-20 7:29 ` Al Viro
1 sibling, 0 replies; 41+ messages in thread
From: Christopher Li @ 2010-10-18 18:43 UTC (permalink / raw)
To: Bernd Petrovitsch; +Cc: Kamil Dudka, Tomas Klacko, linux-sparse, Josh Triplett
On Wed, Oct 13, 2010 at 7:45 AM, Bernd Petrovitsch
<bernd@petrovitsch.priv.at> wrote:
> FWIW, the attached patch should fix that.
>
I will get to that after the 0.4.3 release.
Thanks
Chris
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-18 18:37 ` Christopher Li
@ 2010-10-19 20:03 ` Tomas Klacko
2010-10-19 21:31 ` Al Viro
0 siblings, 1 reply; 41+ messages in thread
From: Tomas Klacko @ 2010-10-19 20:03 UTC (permalink / raw)
To: Christopher Li; +Cc: Josh Triplett, Al Viro, linux-sparse
[-- Attachment #1: Type: text/plain, Size: 19856 bytes --]
Hi,
On Mon, Oct 18, 2010 at 8:37 PM, Christopher Li <sparse@chrisli.org> wrote:
> On Sun, Oct 17, 2010 at 10:39 PM, Josh Triplett <josh@joshtriplett.org> wrote:
>>
>> Based on these two code examples, I think you don't need to change
>> CHECK_TYPE at all. (And the user should always use code like your
>> second example, not your first example.)
>
> Oh good, then we can completely remove the #ifdef __cplusplus.
I have removed the #ifdef __cplusplus and the dead label union.
This is the attached patch:
From 68743b26a471a5f59a0efb2929f2dfc82f7eae1a Mon Sep 17 00:00:00 2001
From: Tomas Klacko <tomas.klacko@gmail.com>
Date: Tue, 19 Oct 2010 18:36:53 +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 | 4 ----
pre-process.c | 10 +++++-----
ptrlist.h | 4 ++--
symbol.c | 10 +++++-----
symbol.h | 15 ++++++++-------
token.h | 4 ++--
14 files changed, 58 insertions(+), 60 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..b26bd03 100644
--- a/parse.h
+++ b/parse.h
@@ -35,10 +35,6 @@ struct statement {
struct /* declaration */ {
struct symbol_list *declaration;
};
- struct /* label_arg */ {
- struct symbol *label;
- struct statement *label_statement;
- };
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..b884e4d 100644
--- a/ptrlist.h
+++ b/ptrlist.h
@@ -39,7 +39,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 +270,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
Tomas Klacko
[-- Attachment #2: 0001-Make-headers-usable-in-Cxx-code.patch --]
[-- Type: text/x-diff, Size: 18771 bytes --]
From 68743b26a471a5f59a0efb2929f2dfc82f7eae1a Mon Sep 17 00:00:00 2001
From: Tomas Klacko <tomas.klacko@gmail.com>
Date: Tue, 19 Oct 2010 18:36:53 +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 | 4 ----
pre-process.c | 10 +++++-----
ptrlist.h | 4 ++--
symbol.c | 10 +++++-----
symbol.h | 15 ++++++++-------
token.h | 4 ++--
14 files changed, 58 insertions(+), 60 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..b26bd03 100644
--- a/parse.h
+++ b/parse.h
@@ -35,10 +35,6 @@ struct statement {
struct /* declaration */ {
struct symbol_list *declaration;
};
- struct /* label_arg */ {
- struct symbol *label;
- struct statement *label_statement;
- };
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..b884e4d 100644
--- a/ptrlist.h
+++ b/ptrlist.h
@@ -39,7 +39,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 +270,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
^ permalink raw reply related [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-19 20:03 ` Tomas Klacko
@ 2010-10-19 21:31 ` Al Viro
2010-10-19 21:46 ` David Malcolm
` (2 more replies)
0 siblings, 3 replies; 41+ messages in thread
From: Al Viro @ 2010-10-19 21:31 UTC (permalink / raw)
To: Tomas Klacko; +Cc: Christopher Li, Josh Triplett, linux-sparse
On Tue, Oct 19, 2010 at 10:03:42PM +0200, Tomas Klacko wrote:
> @@ -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,
> };
Egads... Why not "kC1455", while you are at it? Seriously, if you feel the
need to rename that, at least use something more palatable. Hell, even
adjust_type would be better...
The only thing using that field is parsing of declaration specifiers. We
keep track of what's acceptable after the prefix we'd seen (and report
conflicts). We remember if we'd seen a speficier that doesn't combine with
anything (struct/union/enum/void/_Bool/typeof/__builtin_va_list) and for
numeric ones we are using a bit of trick: assign them pairs of integers as
below and add those up.
int: (0,0)
short: (-1,0)
long: (1,0)
signed: (0,1)
unsigned: (0,2)
double: (0, 3)
float: (-1, 3)
char: (0, 4)
Then the sum will be sufficient to discriminate between the resulting types
of acceptable sequences of numeric specifiers. Namely, if the sum is (s,t),
the type we have is
| s = -1 | 0 | 1 | 2 |
t=0|short int |int |long int |long long int |
t=1|short signed int |signed int |long signed int |long long signed int |
t=2|short unsigned int|unsigned int |long unsigned int|long long unsigned int|
t=3|float |double |long double | |
t=4| |char | | |
t=5| |signed char | | |
t=6| |unsigned char| | |
and neither reordering the sequence nor omitting int affect the sum.
The first component of pair is encoded in ->type (KW_SHORT and KW_LONG bits),
the second is stored in ->class. ->test and ->set drive the rejection of
unacceptable sequences. For the sake of completeness, meanings of the bits
in these are:
Set_T seen int/char/double/float/any non-combinable
Set_S seen any non-combinable
Set_{Char,Int,Double,Float,Signed,Unsigned,Short,Long} obvious
Set_Vlong seen either long twice or both long and double
We could conflate e.g. Set_Signed with Set_Unsigned, but we'd have harder
time generating error messages that way. ->test is "reject if we'd already
seen..." and ->set is "we've just seen...". The only things not covered by
the above are
* double long and long double are OK, but triple long and long long
double should be rejected
* if we'd already seen any type specifiers by the time we run into
a typedef name, the sequence ends just before that typedef name (i.e.
typedef char T; int f(long T) is OK and declares f as int(long int)).
That's it...
> 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;
What was that one for?
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
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-19 23:07 ` Christopher Li
2 siblings, 1 reply; 41+ messages in thread
From: David Malcolm @ 2010-10-19 21:46 UTC (permalink / raw)
To: Al Viro; +Cc: Tomas Klacko, Christopher Li, Josh Triplett, linux-sparse
On Tue, 2010-10-19 at 22:31 +0100, Al Viro wrote:
> On Tue, Oct 19, 2010 at 10:03:42PM +0200, Tomas Klacko wrote:
> > @@ -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,
> > };
>
> Egads... Why not "kC1455", while you are at it? Seriously, if you feel the
> need to rename that, at least use something more palatable. Hell, even
> adjust_type would be better...
FWIW, "klass" is used as a spelling of "class" in .c code by Ruby, by
the GTK/GNOME stack, Mono, OpenJDK, Dalvik, and others.
See e.g.:
http://www.google.com/codesearch?hl=en&start=20&sa=N&as_case=y&q=klass+lang:c
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-19 21:46 ` David Malcolm
@ 2010-10-19 22:12 ` Al Viro
0 siblings, 0 replies; 41+ messages in thread
From: Al Viro @ 2010-10-19 22:12 UTC (permalink / raw)
To: David Malcolm; +Cc: Tomas Klacko, Christopher Li, Josh Triplett, linux-sparse
On Tue, Oct 19, 2010 at 05:46:44PM -0400, David Malcolm wrote:
> On Tue, 2010-10-19 at 22:31 +0100, Al Viro wrote:
> > On Tue, Oct 19, 2010 at 10:03:42PM +0200, Tomas Klacko wrote:
> > > @@ -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,
> > > };
> >
> > Egads... Why not "kC1455", while you are at it? Seriously, if you feel the
> > need to rename that, at least use something more palatable. Hell, even
> > adjust_type would be better...
> FWIW, "klass" is used as a spelling of "class" in .c code by Ruby, by
> the GTK/GNOME stack, Mono, OpenJDK, Dalvik, and others.
I'd say that it's an argument _against_ doing that, if anything...
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-19 21:31 ` Al Viro
2010-10-19 21:46 ` David Malcolm
@ 2010-10-19 22:49 ` Tomas Klacko
2010-10-20 10:19 ` Bernd Petrovitsch
2010-10-19 23:07 ` Christopher Li
2 siblings, 1 reply; 41+ messages in thread
From: Tomas Klacko @ 2010-10-19 22:49 UTC (permalink / raw)
To: Al Viro; +Cc: Christopher Li, Josh Triplett, linux-sparse
On Tue, Oct 19, 2010 at 11:31 PM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> On Tue, Oct 19, 2010 at 10:03:42PM +0200, Tomas Klacko wrote:
>> 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;
>
> What was that one for?
"warning: comparison between signed and unsigned integer expressions"
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
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-19 21:31 ` Al Viro
2010-10-19 21:46 ` David Malcolm
2010-10-19 22:49 ` Tomas Klacko
@ 2010-10-19 23:07 ` Christopher Li
2010-10-20 7:40 ` Al Viro
2 siblings, 1 reply; 41+ messages in thread
From: Christopher Li @ 2010-10-19 23:07 UTC (permalink / raw)
To: Al Viro; +Cc: Tomas Klacko, Josh Triplett, linux-sparse
On Tue, Oct 19, 2010 at 2:31 PM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> On Tue, Oct 19, 2010 at 10:03:42PM +0200, Tomas Klacko wrote:
>> @@ -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,
>> };
>
> Egads... Why not "kC1455", while you are at it? Seriously, if you feel the
> need to rename that, at least use something more palatable. Hell, even
> adjust_type would be better...
I suggested the "klass", my bad. How about your suggest a perfect name
and we will use it. Is "adjust_type" good enough?
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
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
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
1 sibling, 1 reply; 41+ messages in thread
From: Al Viro @ 2010-10-20 7:29 UTC (permalink / raw)
To: Bernd Petrovitsch
Cc: Christopher Li, Kamil Dudka, Tomas Klacko, linux-sparse,
Josh Triplett
On Wed, Oct 13, 2010 at 04:45:10PM +0200, Bernd Petrovitsch wrote:
> rename the local variables "true" and "false" to "if_true" and "if_false",
> respectively to not clash with the well-known "keywords" defined by C99.
> This is similar to commit 0be55c9.
These are not keywords... Said that, things like
if (!cond->value)
true = false;
if (!true)
true = cond;
certainly reek of IOCCC. I'd rather avoid "if_true" as replacement, though.
If anything, true_expr and false_expr would make more sense.
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-19 23:07 ` Christopher Li
@ 2010-10-20 7:40 ` Al Viro
0 siblings, 0 replies; 41+ messages in thread
From: Al Viro @ 2010-10-20 7:40 UTC (permalink / raw)
To: Christopher Li; +Cc: Tomas Klacko, Josh Triplett, linux-sparse
On Tue, Oct 19, 2010 at 04:07:42PM -0700, Christopher Li wrote:
> On Tue, Oct 19, 2010 at 2:31 PM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> > On Tue, Oct 19, 2010 at 10:03:42PM +0200, Tomas Klacko wrote:
> >> @@ -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,
> >> ?};
> >
> > Egads... ?Why not "kC1455", while you are at it? ?Seriously, if you feel the
> > need to rename that, at least use something more palatable. ?Hell, even
> > adjust_type would be better...
>
> I suggested the "klass", my bad. How about your suggest a perfect name
> and we will use it. Is "adjust_type" good enough?
type_group, probably... FWIW, I'd probably spell that enum in parse.c as
CInt = 0, CSInt = 1, CUInt = 2, CReal = 3, CChar = 4,
CSChar = CChar + CSInt, CUChar = CChar + CUInt
while we are at it.
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-20 7:29 ` Al Viro
@ 2010-10-20 9:39 ` Bernd Petrovitsch
2010-10-20 15:34 ` Christopher Li
0 siblings, 1 reply; 41+ messages in thread
From: Bernd Petrovitsch @ 2010-10-20 9:39 UTC (permalink / raw)
To: Christopher Li, Al Viro
Cc: Kamil Dudka, Tomas Klacko, linux-sparse, Josh Triplett
On Mit, 2010-10-20 at 08:29 +0100, Al Viro wrote:
> On Wed, Oct 13, 2010 at 04:45:10PM +0200, Bernd Petrovitsch wrote:
>
> > rename the local variables "true" and "false" to "if_true" and "if_false",
> > respectively to not clash with the well-known "keywords" defined by C99.
> > This is similar to commit 0be55c9.
>
> These are not keywords... Said that, things like
ACK, that's why "keywords" is quoted above.
> if (!cond->value)
> true = false;
> if (!true)
> true = cond;
> certainly reek of IOCCC. I'd rather avoid "if_true" as replacement, though.
> If anything, true_expr and false_expr would make more sense.
I have no strong feelings about the replacement and just followed the
change in the referenced commit.
Chris, should I respin the patch with *_expr?
Bernd
--
mobile: +43 664 4416156 http://www.sysprog.at/
Linux Software Development, Consulting and Services
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-19 22:49 ` Tomas Klacko
@ 2010-10-20 10:19 ` Bernd Petrovitsch
0 siblings, 0 replies; 41+ messages in thread
From: Bernd Petrovitsch @ 2010-10-20 10:19 UTC (permalink / raw)
To: Tomas Klacko; +Cc: Al Viro, Christopher Li, Josh Triplett, linux-sparse
On Mit, 2010-10-20 at 00:49 +0200, Tomas Klacko wrote:
> On Tue, Oct 19, 2010 at 11:31 PM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> > On Tue, Oct 19, 2010 at 10:03:42PM +0200, Tomas Klacko wrote:
>
> >> 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;
> >
> > What was that one for?
>
> "warning: comparison between signed and unsigned integer expressions"
Add "-Wsign-compare" to the CFLAGS (for a pure C compile) and you will
find many more of them.
IMHO it needs a decision if the goal is to prefer signed or unsigned int
(where no negative values ever used/assigned) and convert struct members
and/or global variables. Most of them TTBOMK are never negative anyways.
For the "C vs C++" issue: if you have an enum, the rules (or at least
the reality defined by gcc) are subtly different if it's a signed int or
an unsigned int and the values of their members.
Bernd
--
mobile: +43 664 4416156 http://www.sysprog.at/
Linux Software Development, Consulting and Services
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-20 9:39 ` Bernd Petrovitsch
@ 2010-10-20 15:34 ` Christopher Li
2010-10-29 13:22 ` Bernd Petrovitsch
0 siblings, 1 reply; 41+ messages in thread
From: Christopher Li @ 2010-10-20 15:34 UTC (permalink / raw)
To: Bernd Petrovitsch
Cc: Al Viro, Kamil Dudka, Tomas Klacko, linux-sparse, Josh Triplett
On Wed, Oct 20, 2010 at 2:39 AM, Bernd Petrovitsch <bernd@sysprog.at> wrote:
>> certainly reek of IOCCC. I'd rather avoid "if_true" as replacement, though.
>> If anything, true_expr and false_expr would make more sense.
>
> I have no strong feelings about the replacement and just followed the
> change in the referenced commit.
> Chris, should I respin the patch with *_expr?
Please do. As far as I can remember, Al is always right.
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
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-20 15:34 ` Christopher Li
@ 2010-10-29 13:22 ` Bernd Petrovitsch
2010-11-05 0:57 ` Christopher Li
0 siblings, 1 reply; 41+ messages in thread
From: Bernd Petrovitsch @ 2010-10-29 13:22 UTC (permalink / raw)
To: Christopher Li
Cc: Al Viro, Kamil Dudka, Tomas Klacko, linux-sparse, Josh Triplett
[-- Attachment #1: Type: text/plain, Size: 647 bytes --]
On Mit, 2010-10-20 at 08:34 -0700, Christopher Li wrote:
> On Wed, Oct 20, 2010 at 2:39 AM, Bernd Petrovitsch <bernd@sysprog.at> wrote:
> >> certainly reek of IOCCC. I'd rather avoid "if_true" as replacement, though.
> >> If anything, true_expr and false_expr would make more sense.
> >
> > I have no strong feelings about the replacement and just followed the
> > change in the referenced commit.
> > Chris, should I respin the patch with *_expr?
>
> Please do. As far as I can remember, Al is always right.
Voila.
Bernd
--
mobile: +43 664 4416156 http://www.sysprog.at/
Linux Software Development, Consulting and Services
[-- Attachment #2: 0001-Rename-the-local-variables-true-and-false-to-true_ex.patch --]
[-- Type: text/x-patch, Size: 14360 bytes --]
Rename the local variables "true" and "false" to "true_expr" and
"false_expr" (or another context-sensitive name), respectively to
not clash with the identical "keywords" defined by C99.
The commit 0be55c9 was a step in that direction for .h files only.
Now it is complete.
Signed-off-by: Bernd Petrovitsch <bernd@sysprog.at>
---
compile-i386.c | 18 +++++++++---------
evaluate.c | 22 +++++++++++-----------
expand.c | 18 +++++++++---------
flow.c | 18 +++++++++---------
inline.c | 26 +++++++++++++-------------
linearize.c | 12 ++++++------
pre-process.c | 4 ++--
show-parse.c | 6 +++---
simplify.c | 16 ++++++++--------
9 files changed, 70 insertions(+), 70 deletions(-)
diff --git a/compile-i386.c b/compile-i386.c
index abe9313..1aaf98f 100644
--- a/compile-i386.c
+++ b/compile-i386.c
@@ -1542,7 +1542,7 @@ static struct storage *emit_return_stmt(struct statement *stmt)
static struct storage *emit_conditional_expr(struct expression *expr)
{
- struct storage *cond, *true = NULL, *false = NULL;
+ struct storage *cond, *true_expr = NULL, *false_expr = NULL;
struct storage *new = stack_alloc(expr->ctype->bit_size / 8);
int target_false, cond_end;
@@ -1551,16 +1551,16 @@ static struct storage *emit_conditional_expr(struct expression *expr)
target_false = emit_conditional_test(cond);
/* handle if-true part of the expression */
- true = x86_expression(expr->cond_true);
+ true_expr = x86_expression(expr->cond_true);
- emit_copy(new, true, expr->ctype);
+ emit_copy(new, true_expr, expr->ctype);
cond_end = emit_conditional_end(target_false);
/* handle if-false part of the expression */
- false = x86_expression(expr->cond_false);
+ false_expr = x86_expression(expr->cond_false);
- emit_copy(new, false, expr->ctype);
+ emit_copy(new, false_expr, expr->ctype);
/* end of conditional; jump target for if-true branch */
emit_label(cond_end, "end conditional");
@@ -1571,15 +1571,15 @@ static struct storage *emit_conditional_expr(struct expression *expr)
static struct storage *emit_select_expr(struct expression *expr)
{
struct storage *cond = x86_expression(expr->conditional);
- struct storage *true = x86_expression(expr->cond_true);
- struct storage *false = x86_expression(expr->cond_false);
+ struct storage *true_expr = x86_expression(expr->cond_true);
+ struct storage *false_expr = x86_expression(expr->cond_false);
struct storage *reg_cond, *reg_true, *reg_false;
struct storage *new = stack_alloc(4);
emit_comment("begin SELECT");
reg_cond = get_reg_value(cond, get_regclass(expr->conditional));
- reg_true = get_reg_value(true, get_regclass(expr));
- reg_false = get_reg_value(false, get_regclass(expr));
+ reg_true = get_reg_value(true_expr, get_regclass(expr));
+ reg_false = get_reg_value(false_expr, get_regclass(expr));
/*
* Do the actual select: check the conditional for zero,
diff --git a/evaluate.c b/evaluate.c
index f8343c2..a3ac414 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -1077,7 +1077,7 @@ OK:
*/
static struct symbol *evaluate_conditional_expression(struct expression *expr)
{
- struct expression **true;
+ struct expression **true_expr;
struct symbol *ctype, *ltype, *rtype, *lbase, *rbase;
int lclass, rclass;
const char * typediff;
@@ -1091,18 +1091,18 @@ static struct symbol *evaluate_conditional_expression(struct expression *expr)
ctype = degenerate(expr->conditional);
rtype = degenerate(expr->cond_false);
- true = &expr->conditional;
+ true_expr = &expr->conditional;
ltype = ctype;
if (expr->cond_true) {
if (!evaluate_expression(expr->cond_true))
return NULL;
ltype = degenerate(expr->cond_true);
- true = &expr->cond_true;
+ true_expr = &expr->cond_true;
}
if (expr->flags) {
int flags = expr->conditional->flags & Int_const_expr;
- flags &= (*true)->flags & expr->cond_false->flags;
+ flags &= (*true_expr)->flags & expr->cond_false->flags;
if (!flags)
expr->flags = 0;
}
@@ -1110,27 +1110,27 @@ static struct symbol *evaluate_conditional_expression(struct expression *expr)
lclass = classify_type(ltype, <ype);
rclass = classify_type(rtype, &rtype);
if (lclass & rclass & TYPE_NUM) {
- ctype = usual_conversions('?', *true, expr->cond_false,
+ ctype = usual_conversions('?', *true_expr, expr->cond_false,
lclass, rclass, ltype, rtype);
- *true = cast_to(*true, ctype);
+ *true_expr = cast_to(*true_expr, ctype);
expr->cond_false = cast_to(expr->cond_false, ctype);
goto out;
}
if ((lclass | rclass) & TYPE_PTR) {
- int is_null1 = is_null_pointer_constant(*true);
+ int is_null1 = is_null_pointer_constant(*true_expr);
int is_null2 = is_null_pointer_constant(expr->cond_false);
if (is_null1 && is_null2) {
- *true = cast_to(*true, &ptr_ctype);
+ *true_expr = cast_to(*true_expr, &ptr_ctype);
expr->cond_false = cast_to(expr->cond_false, &ptr_ctype);
ctype = &ptr_ctype;
goto out;
}
if (is_null1 && (rclass & TYPE_PTR)) {
if (is_null1 == 2)
- bad_null(*true);
- *true = cast_to(*true, rtype);
+ bad_null(*true_expr);
+ *true_expr = cast_to(*true_expr, rtype);
ctype = rtype;
goto out;
}
@@ -1198,7 +1198,7 @@ Qual:
sym->ctype.modifiers |= qual;
ctype = sym;
}
- *true = cast_to(*true, ctype);
+ *true_expr = cast_to(*true_expr, ctype);
expr->cond_false = cast_to(expr->cond_false, ctype);
goto out;
}
diff --git a/expand.c b/expand.c
index b965dc3..b7a7a67 100644
--- a/expand.c
+++ b/expand.c
@@ -508,27 +508,27 @@ static int expand_compare(struct expression *expr)
static int expand_conditional(struct expression *expr)
{
struct expression *cond = expr->conditional;
- struct expression *true = expr->cond_true;
- struct expression *false = expr->cond_false;
+ struct expression *true_expr = expr->cond_true;
+ struct expression *false_expr = expr->cond_false;
int cost, cond_cost;
cond_cost = expand_expression(cond);
if (cond->type == EXPR_VALUE) {
unsigned flags = expr->flags;
if (!cond->value)
- true = false;
- if (!true)
- true = cond;
- cost = expand_expression(true);
- *expr = *true;
+ true_expr = false_expr;
+ if (!true_expr)
+ true_expr = cond;
+ cost = expand_expression(true_expr);
+ *expr = *true_expr;
expr->flags = flags;
if (expr->type == EXPR_VALUE)
expr->taint |= cond->taint;
return cost;
}
- cost = expand_expression(true);
- cost += expand_expression(false);
+ cost = expand_expression(true_expr);
+ cost += expand_expression(false_expr);
if (cost < SELECT_COST) {
expr->type = EXPR_SELECT;
diff --git a/flow.c b/flow.c
index 5bd9a1d..aafca03 100644
--- a/flow.c
+++ b/flow.c
@@ -100,7 +100,7 @@ static int try_to_simplify_bb(struct basic_block *bb, struct instruction *first,
struct basic_block *source, *target;
pseudo_t pseudo;
struct instruction *br;
- int true;
+ int true_value;
if (!def)
continue;
@@ -113,10 +113,10 @@ static int try_to_simplify_bb(struct basic_block *bb, struct instruction *first,
continue;
if (br->opcode != OP_BR)
continue;
- true = pseudo_truth_value(pseudo);
- if (true < 0)
+ true_value = pseudo_truth_value(pseudo);
+ if (true_value < 0)
continue;
- target = true ? second->bb_true : second->bb_false;
+ target = true_value ? second->bb_true : second->bb_false;
if (bb_depends_on(target, bb))
continue;
changed |= rewrite_branch(source, &br->bb_true, bb, target);
@@ -165,7 +165,7 @@ static int simplify_phi_branch(struct basic_block *bb, struct instruction *br)
}
static int simplify_branch_branch(struct basic_block *bb, struct instruction *br,
- struct basic_block **target_p, int true)
+ struct basic_block **target_p, int true_expr)
{
struct basic_block *target = *target_p, *final;
struct instruction *insn;
@@ -181,7 +181,7 @@ static int simplify_branch_branch(struct basic_block *bb, struct instruction *br
* Now we just need to see if we can rewrite the branch..
*/
retval = 0;
- final = true ? insn->bb_true : insn->bb_false;
+ final = true_expr ? insn->bb_true : insn->bb_false;
if (bb_has_side_effects(target))
goto try_to_rewrite_target;
if (bb_depends_on(final, target))
@@ -823,13 +823,13 @@ static struct basic_block * rewrite_branch_bb(struct basic_block *bb, struct ins
{
struct basic_block *parent;
struct basic_block *target = br->bb_true;
- struct basic_block *false = br->bb_false;
+ struct basic_block *false_expr = br->bb_false;
- if (target && false) {
+ if (target && false_expr) {
pseudo_t cond = br->cond;
if (cond->type != PSEUDO_VAL)
return NULL;
- target = cond->value ? target : false;
+ target = cond->value ? target : false_expr;
}
/*
diff --git a/inline.c b/inline.c
index 860c0ee..8fa5a7a 100644
--- a/inline.c
+++ b/inline.c
@@ -162,14 +162,14 @@ static struct expression * copy_expression(struct expression *expr)
case EXPR_SELECT:
case EXPR_CONDITIONAL: {
struct expression *cond = copy_expression(expr->conditional);
- struct expression *true = copy_expression(expr->cond_true);
- struct expression *false = copy_expression(expr->cond_false);
- if (cond == expr->conditional && true == expr->cond_true && false == expr->cond_false)
+ struct expression *true_expr = copy_expression(expr->cond_true);
+ struct expression *false_expr = copy_expression(expr->cond_false);
+ if (cond == expr->conditional && true_expr == expr->cond_true && false_expr == expr->cond_false)
break;
expr = dup_expression(expr);
expr->conditional = cond;
- expr->cond_true = true;
- expr->cond_false = false;
+ expr->cond_true = true_expr;
+ expr->cond_false = false_expr;
break;
}
@@ -353,20 +353,20 @@ static struct statement *copy_one_statement(struct statement *stmt)
}
case STMT_IF: {
struct expression *cond = stmt->if_conditional;
- struct statement *true = stmt->if_true;
- struct statement *false = stmt->if_false;
+ struct statement *true_expr = stmt->if_true;
+ struct statement *false_expr = stmt->if_false;
cond = copy_expression(cond);
- true = copy_one_statement(true);
- false = copy_one_statement(false);
+ true_expr = copy_one_statement(true_expr);
+ false_expr = copy_one_statement(false_expr);
if (stmt->if_conditional == cond &&
- stmt->if_true == true &&
- stmt->if_false == false)
+ stmt->if_true == true_expr &&
+ stmt->if_false == false_expr)
break;
stmt = dup_statement(stmt);
stmt->if_conditional = cond;
- stmt->if_true = true;
- stmt->if_false = false;
+ stmt->if_true = true_expr;
+ stmt->if_false = false_expr;
break;
}
case STMT_RETURN: {
diff --git a/linearize.c b/linearize.c
index f2034ce..94d5ea2 100644
--- a/linearize.c
+++ b/linearize.c
@@ -1287,19 +1287,19 @@ pseudo_t linearize_cond_branch(struct entrypoint *ep, struct expression *expr, s
static pseudo_t linearize_select(struct entrypoint *ep, struct expression *expr)
{
- pseudo_t cond, true, false, res;
+ pseudo_t cond, true_expr, false_expr, res;
struct instruction *insn;
- true = linearize_expression(ep, expr->cond_true);
- false = linearize_expression(ep, expr->cond_false);
+ true_expr = linearize_expression(ep, expr->cond_true);
+ false_expr = linearize_expression(ep, expr->cond_false);
cond = linearize_expression(ep, expr->conditional);
insn = alloc_typed_instruction(OP_SEL, expr->ctype);
if (!expr->cond_true)
- true = cond;
+ true_expr = cond;
use_pseudo(insn, cond, &insn->src1);
- use_pseudo(insn, true, &insn->src2);
- use_pseudo(insn, false, &insn->src3);
+ use_pseudo(insn, true_expr, &insn->src2);
+ use_pseudo(insn, false_expr, &insn->src3);
res = alloc_pseudo(insn);
insn->target = res;
diff --git a/pre-process.c b/pre-process.c
index 656acaa..56ddcb6 100644
--- a/pre-process.c
+++ b/pre-process.c
@@ -1236,13 +1236,13 @@ static int handle_strong_undef(struct stream *stream, struct token **line, struc
return do_handle_undef(stream, line, token, SYM_ATTR_STRONG);
}
-static int preprocessor_if(struct stream *stream, struct token *token, int true)
+static int preprocessor_if(struct stream *stream, struct token *token, int condition_is_true)
{
token_type(token) = false_nesting ? TOKEN_SKIP_GROUPS : TOKEN_IF;
free_preprocessor_line(token->next);
token->next = stream->top_if;
stream->top_if = token;
- if (false_nesting || true != 1)
+ if (false_nesting || condition_is_true != 1)
false_nesting++;
return 0;
}
diff --git a/show-parse.c b/show-parse.c
index c97debe..fb84bdc 100644
--- a/show-parse.c
+++ b/show-parse.c
@@ -1001,11 +1001,11 @@ static int show_label_expr(struct expression *expr)
static int show_conditional_expr(struct expression *expr)
{
int cond = show_expression(expr->conditional);
- int true = show_expression(expr->cond_true);
- int false = show_expression(expr->cond_false);
+ int true_expr = show_expression(expr->cond_true);
+ int false_expr = show_expression(expr->cond_false);
int new = new_pseudo();
- printf("[v%d]\tcmov.%d\t\tv%d,v%d,v%d\n", cond, expr->ctype->bit_size, new, true, false);
+ printf("[v%d]\tcmov.%d\t\tv%d,v%d,v%d\n", cond, expr->ctype->bit_size, new, true_expr, false_expr);
return new;
}
diff --git a/simplify.c b/simplify.c
index 8200584..68eeb45 100644
--- a/simplify.c
+++ b/simplify.c
@@ -780,10 +780,10 @@ static int simplify_cond_branch(struct instruction *br, pseudo_t cond, struct in
use_pseudo(br, *pp, &br->cond);
remove_usage(cond, &br->cond);
if (def->opcode == OP_SET_EQ) {
- struct basic_block *true = br->bb_true;
- struct basic_block *false = br->bb_false;
- br->bb_false = true;
- br->bb_true = false;
+ struct basic_block *true_expr = br->bb_true;
+ struct basic_block *false_expr = br->bb_false;
+ br->bb_false = true_expr;
+ br->bb_true = false_expr;
}
return REPEAT_CSE;
}
@@ -836,10 +836,10 @@ static int simplify_branch(struct instruction *insn)
return REPEAT_CSE;
}
if (val2) {
- struct basic_block *true = insn->bb_true;
- struct basic_block *false = insn->bb_false;
- insn->bb_false = true;
- insn->bb_true = false;
+ struct basic_block *true_expr = insn->bb_true;
+ struct basic_block *false_expr = insn->bb_false;
+ insn->bb_false = true_expr;
+ insn->bb_true = false_expr;
}
use_pseudo(insn, def->src1, &insn->cond);
remove_usage(cond, &insn->cond);
--
1.7.2.3
^ permalink raw reply related [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-10-29 13:22 ` Bernd Petrovitsch
@ 2010-11-05 0:57 ` Christopher Li
2010-11-09 13:28 ` Bernd Petrovitsch
0 siblings, 1 reply; 41+ messages in thread
From: Christopher Li @ 2010-11-05 0:57 UTC (permalink / raw)
To: Bernd Petrovitsch
Cc: Al Viro, Kamil Dudka, Tomas Klacko, linux-sparse, Josh Triplett
On Fri, Oct 29, 2010 at 6:22 AM, Bernd Petrovitsch <bernd@sysprog.at> wrote:
>
> Voila.
- struct basic_block *true = br->bb_true;
- struct basic_block *false = br->bb_false;
- br->bb_false = true;
- br->bb_true = false;
+ struct basic_block *true_expr = br->bb_true;
+ struct basic_block *false_expr = br->bb_false;
+ br->bb_false = true_expr;
+ br->bb_true = false_expr;
Hmm, not very "true" symbol is an expression type. You end up calling
basicl_block pointer as true_expr, that is misleading.
Same thing happen to pseudo_t pointers.
Looks fine otherwise.
Chris
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-11-05 0:57 ` Christopher Li
@ 2010-11-09 13:28 ` Bernd Petrovitsch
2010-11-09 22:52 ` Christopher Li
0 siblings, 1 reply; 41+ messages in thread
From: Bernd Petrovitsch @ 2010-11-09 13:28 UTC (permalink / raw)
To: Christopher Li
Cc: Al Viro, Kamil Dudka, Tomas Klacko, linux-sparse, Josh Triplett
Hi!
On Don, 2010-11-04 at 17:57 -0700, Christopher Li wrote:
> On Fri, Oct 29, 2010 at 6:22 AM, Bernd Petrovitsch <bernd@sysprog.at> wrote:
> >
> > Voila.
>
> - struct basic_block *true = br->bb_true;
> - struct basic_block *false = br->bb_false;
> - br->bb_false = true;
> - br->bb_true = false;
> + struct basic_block *true_expr = br->bb_true;
> + struct basic_block *false_expr = br->bb_false;
> + br->bb_false = true_expr;
> + br->bb_true = false_expr;
>
> Hmm, not very "true" symbol is an expression type. You end up calling
> basicl_block pointer as true_expr, that is misleading.
> Same thing happen to pseudo_t pointers.
Frankly, I don't understand what you mean (especially with the pseudo_t)
- which also explains why the suboptimal variable naming and I cannot
come up with a better name.
> Looks fine otherwise.
Bernd
--
mobile: +43 664 4416156 http://www.sysprog.at/
Linux Software Development, Consulting and Services
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-11-09 13:28 ` Bernd Petrovitsch
@ 2010-11-09 22:52 ` Christopher Li
2010-11-10 10:52 ` Bernd Petrovitsch
0 siblings, 1 reply; 41+ messages in thread
From: Christopher Li @ 2010-11-09 22:52 UTC (permalink / raw)
To: Bernd Petrovitsch
Cc: Al Viro, Kamil Dudka, Tomas Klacko, linux-sparse, Josh Triplett
On Tue, Nov 9, 2010 at 5:28 AM, Bernd Petrovitsch <bernd@sysprog.at> wrote:
> Frankly, I don't understand what you mean (especially with the pseudo_t)
> - which also explains why the suboptimal variable naming and I cannot
> come up with a better name.
Oh, sorry for the confusion. I mean the you can use some thing like:
true_pseudo and
false_pseudo instead of calling it expressions. Pseduo is not an expression.
I will make that adjustment for you and post the patch on the list. If Al don't
complain I will submit it. All right?
Chris
^ permalink raw reply [flat|nested] 41+ messages in thread
* Re: including sparse headers in C++ code
2010-11-09 22:52 ` Christopher Li
@ 2010-11-10 10:52 ` Bernd Petrovitsch
0 siblings, 0 replies; 41+ messages in thread
From: Bernd Petrovitsch @ 2010-11-10 10:52 UTC (permalink / raw)
To: Christopher Li
Cc: Al Viro, Kamil Dudka, Tomas Klacko, linux-sparse, Josh Triplett
On Die, 2010-11-09 at 14:52 -0800, Christopher Li wrote:
> On Tue, Nov 9, 2010 at 5:28 AM, Bernd Petrovitsch <bernd@sysprog.at> wrote:
> > Frankly, I don't understand what you mean (especially with the pseudo_t)
> > - which also explains why the suboptimal variable naming and I cannot
> > come up with a better name.
>
> Oh, sorry for the confusion. I mean the you can use some thing like:
> true_pseudo and
> false_pseudo instead of calling it expressions. Pseduo is not an expression.
>
> I will make that adjustment for you and post the patch on the list. If Al don't
> complain I will submit it. All right?
Yes, please.
Signed-off-by: Bernd Petrovitsch <bernd@sysprog.at>
Bernd
--
mobile: +43 664 4416156 http://www.sysprog.at/
Linux Software Development, Consulting and Services
^ permalink raw reply [flat|nested] 41+ messages in thread
end of thread, other threads:[~2010-11-10 10:52 UTC | newest]
Thread overview: 41+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).