diff options
author | Al Viro <viro@ZenIV.linux.org.uk> | 2009-02-06 05:36:55 +0000 |
---|---|---|
committer | Christopher Li <sparse@chrisli.org> | 2009-07-17 23:06:22 +0000 |
commit | c121815ecdcefdb735e92fae6ba9eedca88fe289 (patch) | |
tree | 4200b409668c20feb8a1a8837aabe1e7e0fcea1b /validation | |
parent | Fix type_info_expression() (diff) | |
download | sparse-c121815ecdcefdb735e92fae6ba9eedca88fe289.tar.gz sparse-c121815ecdcefdb735e92fae6ba9eedca88fe289.tar.bz2 sparse-c121815ecdcefdb735e92fae6ba9eedca88fe289.zip |
fun with declarations and definitions
On Thu, Feb 05, 2009 at 09:19:21PM +0000, Al Viro wrote:
> IOW, direct_declarator() (which doubles for direct-abstract-declarator) should
> have more than one-bit indication of which case we've got. Right now it's
> done by "have we passed a non-NULL ident ** to store the identifier being
> declared"; that's not enough. What we need is explicit 'is that a part of
> parameter declaration' flag; then the rule turns into
> if (p && *p)
> fn = 1; /* we'd seen identifier already, can't be nested */
> else if match_op(next, ')')
> fn = 1; /* empty list can't be direct-declarator or
> * direct-abstract-declarator */
> else
> fn = (in_parameter && lookup_type(next));
Umm... It's a bit more subtle (p goes NULL after the nested one is
handled), so we need to keep track of "don't allow nested declarator from
that point on" explicitly. Patch follows:
Subject: [PATCH] Handle nested declarators vs. parameter lists correctly
Seeing a typedef name after ( means that we have a parameter-type-list
only if we are parsing a parameter declaration or a typename; otherwise
it might very well be a redeclaration (e.g. int (T); when T had been a
typedef in outer scope).
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/nested-declarator.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/validation/nested-declarator.c b/validation/nested-declarator.c new file mode 100644 index 0000000..24ed833 --- /dev/null +++ b/validation/nested-declarator.c @@ -0,0 +1,11 @@ +typedef int T; +extern void f(int); +static void g(int x) +{ + int (T); + T = x; + f(T); +} +/* + * check-name: nested declarator vs. parameters + */ |