aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2009-02-14 12:25:25 +0000
committerChristopher Li <sparse@chrisli.org>2009-07-17 23:06:22 +0000
commitdc16c4ea09e27f9c15c58b787f7ee3e110e0b8a4 (patch)
tree34cebdc0917b346f2a7006c7cb827a56884e1ee0
parent9151897c4a2557382b4a4a64e1e3a0fae41747e0 (diff)
downloadsparse-dc16c4ea09e27f9c15c58b787f7ee3e110e0b8a4.tar.gz
More nested declarator fixes
no nested declarators after [...] or (parameters) Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Christopher Li <sparse@chrisli.org>
-rw-r--r--parse.c2
-rw-r--r--validation/nested-declarator.c16
2 files changed, 18 insertions, 0 deletions
diff --git a/parse.c b/parse.c
index 27338355..7af26137 100644
--- a/parse.c
+++ b/parse.c
@@ -1220,6 +1220,7 @@ static struct token *direct_declarator(struct token *token, struct symbol *decl,
token = parameter_type_list(next, sym, p);
token = expect(token, ')', "in function declarator");
sym->endpos = token->pos;
+ dont_nest = 1;
continue;
}
if (token->special == '[') {
@@ -1228,6 +1229,7 @@ static struct token *direct_declarator(struct token *token, struct symbol *decl,
token = expect(token, ']', "in abstract_array_declarator");
array->endpos = token->pos;
ctype = &array->ctype;
+ dont_nest = 1;
continue;
}
break;
diff --git a/validation/nested-declarator.c b/validation/nested-declarator.c
index 24ed8337..62c49401 100644
--- a/validation/nested-declarator.c
+++ b/validation/nested-declarator.c
@@ -6,6 +6,22 @@ static void g(int x)
T = x;
f(T);
}
+static void h(void)
+{
+ static int [2](T)[3];
+}
+static int [2](*p)[3];
+int i(void (void)(*f));
+int j(int [2](*));
/*
* check-name: nested declarator vs. parameters
+ * check-error-start:
+nested-declarator.c:11:29: warning: missing identifier in declaration
+nested-declarator.c:13:16: error: Expected ) in function declarator
+nested-declarator.c:13:16: error: got *
+nested-declarator.c:14:19: error: Expected ) in function declarator
+nested-declarator.c:14:19: error: got *
+nested-declarator.c:15:15: error: Expected ) in function declarator
+nested-declarator.c:15:15: error: got *
+ * check-error-end:
*/