aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Matz <matz@suse.de>2017-05-05 22:01:02 +0200
committerMichael Matz <matz@suse.de>2017-05-05 22:01:02 +0200
commita7a3627ab2f9f06e7725c6b6c796984684d0fdb8 (patch)
tree857f9f8e1979ebec82f1680170c0c671aed83cd2
parentd4878985e85c01888c917a2ebcb5c533961fe53b (diff)
downloadtinycc-a7a3627ab2f9f06e7725c6b6c796984684d0fdb8.tar.gz
tinycc-a7a3627ab2f9f06e7725c6b6c796984684d0fdb8.tar.bz2
Fix segfault with invalid function def
This invalid function definition: int f()[] {} was tried to be handled but there was no testcase if it actually worked. This fixes it and adds a TCC only testcase.
-rw-r--r--tccgen.c2
-rw-r--r--tests/tcctest.c5
2 files changed, 6 insertions, 1 deletions
diff --git a/tccgen.c b/tccgen.c
index d7a5488..cbfe5ff 100644
--- a/tccgen.c
+++ b/tccgen.c
@@ -4013,7 +4013,7 @@ static int post_type(CType *type, AttributeDef *ad, int storage, int td)
if (tok == '[') {
next();
skip(']'); /* only handle simple "[]" */
- type->t |= VT_PTR;
+ mk_pointer(type);
}
/* we push a anonymous symbol which will contain the function prototype */
ad->a.func_args = arg_size;
diff --git a/tests/tcctest.c b/tests/tcctest.c
index e86a2a6..b6e4116 100644
--- a/tests/tcctest.c
+++ b/tests/tcctest.c
@@ -176,6 +176,11 @@ static int onetwothree = 123;
#define B3 4
#endif
+#ifdef __TINYC__
+/* We try to handle this syntax. Make at least sure it doesn't segfault. */
+char invalid_function_def()[] {}
+#endif
+
#define __INT64_C(c) c ## LL
#define INT64_MIN (-__INT64_C(9223372036854775807)-1)