Hello.
The code:
enum whatever var;
In that case struct_union_enum_specifier() will not call
*parse == parse_enum_declaration, because it does not see
'{' token. This means that SYM_ENUM->ctype.base_type == 0.
Now almost any usage of var will segfault in is_int_type(),
for example:
0 == var;
I don't know what would be the proper fix, but why is_int_type()
does not look like:
static inline int is_int_type(const struct symbol *type)
{
if (type->type == SYM_NODE)
type = type->ctype.base_type;
return type->type == SYM_ENUM ||
type->type == SYM_BITFIELD ||
type->ctype.base_type == &int_type;
}
?
Yes, we may have ->base_type == &bad_ctype, but it was supposed
to be {int,ulong,...}_ctype anyway, and &bad_ctype means compile
error anyway.
And this error (I think) shoud be reported in parse_enum_declaration.
Instead sparse reports error from examine_enum_type() when the code
tries to use this enum:
enum E1 {};
enum E2 {};
static void tst(void)
{
enum E2 e2;
enum E1 e1;
}
output:
tst.c:2:6: warning: invalid enum type
tst.c:1:6: warning: invalid enum type
Note the order of lines in error messages, it could be confusing.
And examine_enum_type() gives the same message for 2 different
cases:
base_type == NULL // forward declaration
base_type == &bad_ctype // compile error
Oleg.
-
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