Thomas Schmid wrote:
> [EMAIL PROTECTED] schrieb am 02.08.2007 02:15:34:
>
>> Another annoying thing is that the types are always resolved for
>> typedefs. i.e. for
>>
>> typedef int foo;
>> foo bar;
>>
>> the symbol for bar has a base type of int.
>
> ...and a base_type->ident named "foo". But if you add another typedef on
> "int", i.e.
>
> typedef int DINT;
>
> base_type->ident changes to "DINT", now there's no way to get out, that
> symbol "bar" was declared with "foo".
> Tell me if I'm wrong, but a solution for this would also help me on that:
> http://marc.info/?l=linux-sparse&m=118171213001092&w=2
>
>> Any suggestions for how to solve this would be greatly appreciated :)
> I agree! ;-)
Ok, I've hacked up a little patch that does a small bit of the job
(attached), but this breaks comparisons to abstract types (and probably
a whole load more besides). I'll carry on hacking this some more and see
if I can sort those issues, but I'd greatly appreciate some input from
anyone with deeper knowledge!
Thanks,
Rob Taylor
>From 06cae878ce87d71bb5c827c4e8df7f3e5a1df40f Mon Sep 17 00:00:00 2001
From: Rob Taylor <[EMAIL PROTECTED]>
Date: Fri, 3 Aug 2007 01:37:58 +0100
Subject: [PATCH] cracked ideas to track user types.
---
c2xml.c | 6 ++++--
parse.c | 7 +++++--
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/c2xml.c b/c2xml.c
index 37f29cf..42f059e 100644
--- a/c2xml.c
+++ b/c2xml.c
@@ -166,8 +166,6 @@ static void examine_symbol(struct symbol *sym, xmlNodePtr node)
return;
child = new_sym_node(sym, get_type_name(sym->type), node);
- examine_modifiers(sym, child);
- examine_layout(sym, child);
if (sym->ctype.base_type) {
if ((base = builtin_typename(sym->ctype.base_type)) == NULL) {
@@ -199,6 +197,10 @@ static void examine_symbol(struct symbol *sym, xmlNodePtr node)
newProp(child, "base-type-builtin", builtin_typename(sym));
break;
}
+
+ examine_modifiers(sym, child);
+ examine_layout(sym, child);
+
return;
}
diff --git a/parse.c b/parse.c
index f452042..1ac7586 100644
--- a/parse.c
+++ b/parse.c
@@ -1101,12 +1101,15 @@ static struct token *declaration_specifiers(struct token *next, struct ctype *ct
break;
if (ctype->base_type)
break;
- /* User types only mix with qualifiers */
if (mod & MOD_USERTYPE) {
+ /* User types only mix with qualifiers */
if (ctype->modifiers & MOD_SPECIFIER)
break;
+ /* Point to the user type */
+ ctype->base_type = s;
}
- ctype->base_type = type;
+ else
+ ctype->base_type = type;
}
check_modifiers(&token->pos, s, ctype->modifiers);
--
1.5.3.GIT