diff options
| author | Al Viro <viro@ftp.linux.org.uk> | 2009-02-14 12:25:05 +0000 |
|---|---|---|
| committer | Christopher Li <sparse@chrisli.org> | 2009-07-17 23:06:22 +0000 |
| commit | 65f354637410d2c5d33a6ca425a67ceacdd7cea0 (patch) | |
| tree | 6be3b4c899174015b99664f18d1637471ee01f2f /validation | |
| parent | 801c6d64cae47d0c7ffc55c53a0f3c599bc0dcaf (diff) | |
| download | sparse-dev-65f354637410d2c5d33a6ca425a67ceacdd7cea0.tar.gz | |
Fix handling of ident-less declarations
The rule for ident-less declaration is
declaration -> declaration-specifiers ;
not
declaration -> declaration-specifiers abstract-declarator;
IOW, struct foo; is OK and so's struct foo {int x; int y;} (and even
simply int; is allowed by syntax - it's rejected by constraints, but
that's a separate story), but not struct foo (void); and its ilk.
See C99 6.7p1 for syntax; C90 is the same in that area and gcc also
behaves the same way. Unlike gcc I've made it a warning (gcc produces
a hard error for those).
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/missing-ident.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/validation/missing-ident.c b/validation/missing-ident.c new file mode 100644 index 00000000..ce73983d --- /dev/null +++ b/validation/missing-ident.c @@ -0,0 +1,18 @@ +int [2]; +int *; +int (*); +int (); +int; +struct foo; +union bar {int x; int y;}; +struct baz {int x, :3, y:2;}; +/* + * check-name: handling of identifier-less declarations + * + * check-error-start +missing-ident.c:1:8: warning: missing identifier in declaration +missing-ident.c:2:6: warning: missing identifier in declaration +missing-ident.c:3:8: warning: missing identifier in declaration +missing-ident.c:4:7: warning: missing identifier in declaration + * check-error-end + */ |
