Incomplete enum type has ->ctype.base_type == NULL, so almost any
usage of it segfaults in is_int_type(), example:
enum E *p;
*p == 0;
It is not possible (and wrong) to fix only the is_int_type(), we
also need valid ->base_type in integer_promotion, get_sym_type, etc.
This patch also "fixes" false error message:
The code:
extern enum E e;
static void *p = &e;
output:
enum.c:1:13: warning: invalid enum type
Signed-off-by: Oleg Nesterov <[EMAIL PROTECTED]>
--- git-snapshot-20050816/parse.c~2_enum 2005-08-17 15:11:11.000000000
+0400
+++ git-snapshot-20050816/parse.c 2005-08-17 19:44:09.000000000 +0400
@@ -317,7 +317,13 @@ static struct token *parse_enum_declarat
static struct token *enum_specifier(struct token *token, struct ctype *ctype)
{
- return struct_union_enum_specifier(SYM_ENUM, token, ctype,
parse_enum_declaration);
+ struct token *ret = struct_union_enum_specifier(SYM_ENUM, token, ctype,
parse_enum_declaration);
+
+ ctype = &ctype->base_type->ctype;
+ if (!ctype->base_type)
+ ctype->base_type = &incomplete_ctype;
+
+ return ret;
}
static struct token *typeof_specifier(struct token *token, struct ctype *ctype)
--- git-snapshot-20050816/symbol.c~2_enum 2005-08-15 21:43:30.000000000
+0400
+++ git-snapshot-20050816/symbol.c 2005-08-17 20:37:07.000000000 +0400
@@ -323,7 +323,7 @@ static struct symbol *examine_enum_type(
{
struct symbol *base_type = examine_base_type(sym);
- if (!base_type || base_type == &bad_ctype) {
+ if (base_type == &bad_ctype) {
warning(sym->pos, "invalid enum type");
sym->bit_size = -1;
return sym;
-
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html