diff options
author | Geoff Johnstone <geoff.johnstone@googlemail.com> | 2008-04-05 02:59:06 -0700 |
---|---|---|
committer | Josh Triplett <josh@freedesktop.org> | 2008-04-05 02:59:06 -0700 |
commit | 08431f18af58bb612976185000a465bf8168582b (patch) | |
tree | 8f95aecca93189da98ac83b5282b746b8b909bc8 | |
parent | 27be02d4055500ab7a3f8607f9daef044375b155 (diff) | |
download | sparse-08431f18af58bb612976185000a465bf8168582b.tar.gz |
Fix type mismatches with incomplete types
If I put the following in a public header:
struct foo;
typedef struct foo *Foo;
void func (Foo f);
and the definition of struct foo in a private header:
struct foo { int bar; }
then I get a sparse warning (different base type for argument 1) when
I compile the implementation file:
#include "public.h"
#include "private.h"
void func (Foo f) { ... }
i.e. sparse doesn't realise that the incomplete structure definition
in the function prototype refers to the same type as the complete
structure definition in the function definition.
*I think* that the patch fixes this - it silences the error - but I
don't know enough about sparse to know whether it's correct (or
whether it silences other legitimate errors, for example).
Signed-off-by: Geoff Johnstone <geoff.johnstone@googlemail.com>
-rw-r--r-- | evaluate.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -697,8 +697,12 @@ const char *type_difference(struct ctype *c1, struct ctype *c2, type); return "bad types"; case SYM_RESTRICT: + return "different base types"; case SYM_UNION: case SYM_STRUCT: + /* allow definition of incomplete structs and unions */ + if (t1->ident == t2->ident) + return NULL; return "different base types"; case SYM_ARRAY: /* XXX: we ought to compare sizes */ |