started collecting some parser tests
authorMatthias Braun <matze@braunis.de>
Mon, 19 Nov 2007 20:40:43 +0000 (20:40 +0000)
committerMatthias Braun <matze@braunis.de>
Mon, 19 Nov 2007 20:40:43 +0000 (20:40 +0000)
[r18490]

parsetest/declarator_special.c [new file with mode: 0644]
parsetest/initializers.c [new file with mode: 0644]
parsetest/shouldfail/brace1.c [new file with mode: 0644]
parsetest/shouldfail/brace2.c [new file with mode: 0644]

diff --git a/parsetest/declarator_special.c b/parsetest/declarator_special.c
new file mode 100644 (file)
index 0000000..75964ad
--- /dev/null
@@ -0,0 +1,14 @@
+int f(void)
+{
+       return 42;
+}
+
+int (* const (fip) (void))(void)
+{
+       return &f;
+}
+
+int main(void) {
+       int(*func)(void) = fip();
+       return func() == 42 ? 0 : 1;
+}
diff --git a/parsetest/initializers.c b/parsetest/initializers.c
new file mode 100644 (file)
index 0000000..7c473b0
--- /dev/null
@@ -0,0 +1,43 @@
+int bla = 1;
+int bla2 = 2;
+int bla3 = { 3 };
+int bla4 = { 4, };
+/* should fail:
+int bla5 = { { 2 } };
+int bla6 = { 1, 2 };
+int *bla7 = { 2, };
+int bla5 = 1, ;
+*/
+
+char str1[] = "Hello";
+char str2[5] = "Hello";
+char str3[10] = "Hello";
+signed char str4[] = "Hello";
+unsigned char str5[] = "Hello";
+/* char str4[4] = "Hello"; unclear wether this should be an error or warning
+ * gcc produces a warning, icc an error */
+
+struct foo {
+       int a, b;
+};
+
+struct foo f1 = { 1, 2 };
+struct foo f2 = { { 1, }, 2 }; /* produces a warning on icc and gcc... */
+struct foo f3 = { { { 1, } }, 2 }; /* produces a warning on icc and gcc... */
+
+struct foob {
+       int a;
+       struct foobb {
+               float c, d;
+       };
+       int e;
+};
+
+struct foob ff2 = { 1, 2.5, 4, 2 };
+
+union foou {
+       int a;
+       float b;
+};
+
+union foou g1 = { 5 };
diff --git a/parsetest/shouldfail/brace1.c b/parsetest/shouldfail/brace1.c
new file mode 100644 (file)
index 0000000..cb0749c
--- /dev/null
@@ -0,0 +1,2 @@
+int main(int argc, char **argv)
+{
diff --git a/parsetest/shouldfail/brace2.c b/parsetest/shouldfail/brace2.c
new file mode 100644 (file)
index 0000000..5c34318
--- /dev/null
@@ -0,0 +1 @@
+}