aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2009-02-14 12:25:45 +0000
committerChristopher Li <sparse@chrisli.org>2009-07-17 23:06:23 +0000
commitf0ae32de03f4c41018c0733f534eb395d28666bb (patch)
tree27d146f74f9d57376cebe3d6f675af5b4d77826f /validation
parentFix attribute/asm handling (diff)
downloadsparse-f0ae32de03f4c41018c0733f534eb395d28666bb.tar.gz
sparse-f0ae32de03f4c41018c0733f534eb395d28666bb.tar.bz2
sparse-f0ae32de03f4c41018c0733f534eb395d28666bb.zip
more direct_declarator() sanitizing
* new helper function - which_kind(). Finds how to parse what follows ( in declarator. * parameter-type-list and identifier-list handling separated and cleaned up. * saner recovery from errors * int f(__attribute__((....)) x) is prohibited by gcc syntax; attributes are not allowed in K&R identifier list, obviously, and gcc refused to treat that as "int is implicit if missing" kind of case. 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-declarator2.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/validation/nested-declarator2.c b/validation/nested-declarator2.c
new file mode 100644
index 0000000..700c802
--- /dev/null
+++ b/validation/nested-declarator2.c
@@ -0,0 +1,40 @@
+typedef int T;
+extern void f1(int);
+extern void f2(T);
+static void (*f3)(int) = f2;
+static void (*f4)(T) = f1;
+extern void f5(void (int));
+extern void f6(void (T));
+static void z(int x)
+{
+ int (T) = x;
+ f5(f2);
+ f6(f3);
+}
+static void f8();
+static int (x) = 1;
+static void w1(y)
+int y;
+{
+ x = y;
+}
+static void w2(int ());
+static void w3(...);
+static void f9(__attribute__((mode(DI))) T);
+static void bad1(__attribute__((mode(DI))) x);
+static int (-bad2);
+static void [2](*bad3);
+/*
+ * check-name: more on handling of ( in direct-declarator
+ * check-error-start:
+nested-declarator2.c:17:1: warning: non-ANSI definition of function 'w1'
+nested-declarator2.c:21:21: warning: non-ANSI function declaration of function '<noident>'
+nested-declarator2.c:22:16: warning: variadic functions must have one named argument
+nested-declarator2.c:24:44: error: Expected ) in function declarator
+nested-declarator2.c:24:44: error: got x
+nested-declarator2.c:25:13: error: Expected ) in nested declarator
+nested-declarator2.c:25:13: error: got -
+nested-declarator2.c:26:17: error: Expected ) in function declarator
+nested-declarator2.c:26:17: error: got *
+ * check-error-end:
+ */