From 161bbec262545b883c983e1810c942116a3bebdc Mon Sep 17 00:00:00 2001 From: Dale Weiler Date: Thu, 31 Jul 2014 00:43:08 -0400 Subject: [PATCH] Parameter omitting in fteqcc is disallowed. --- parser.c | 4 ++++ tests/defs.qh | 30 +++++++++++++++--------------- tests/noreturn.qc | 3 +-- tests/paramomit.qc | 3 +++ tests/paramomit.tmpl | 4 ++++ tests/pointlife.qc | 2 +- tests/typedefs.qc | 4 ++-- tests/varargs.qc | 2 +- 8 files changed, 31 insertions(+), 21 deletions(-) create mode 100644 tests/paramomit.qc create mode 100644 tests/paramomit.tmpl diff --git a/parser.c b/parser.c index b7d4bf5..0d251d1 100644 --- a/parser.c +++ b/parser.c @@ -4675,6 +4675,10 @@ static ast_value *parse_parameter_list(parser_t *parser, ast_value *var) } } } else { + if (OPTS_OPTION_U32(OPTION_STANDARD) == COMPILER_FTEQCC && param->name[0] == '<') { + parseerror(parser, "parameter name omitted %s %d", param->name, vec_size(params)); + goto on_error; + } vec_push(params, param); if (param->expression.vtype >= TYPE_VARIANT) { char tname[1024]; /* typename is reserved in C++ */ diff --git a/tests/defs.qh b/tests/defs.qh index ed8a5df..f6ea408 100644 --- a/tests/defs.qh +++ b/tests/defs.qh @@ -3,18 +3,18 @@ // builtins. I no event shall you even consider adding // these individually per test. -void (string, ...) print = #1; -string (float) ftos = #2; -entity () spawn = #3; -void (entity) kill = #4; -string (vector) vtos = #5; -void (string) error = #6; -float (vector) vlen = #7; -string (entity) etos = #8; -float (string) stof = #9; -string (...) strcat = #10; -float (string, string) strcmp = #11; -vector (vector) normalize = #12; -float (float) sqrt = #13; -float (float) floor = #14; -float (float, float) pow = #15; +void (string str, ...) print = #1; +string (float val) ftos = #2; +entity () spawn = #3; +void (entity ent) kill = #4; +string (vector vec) vtos = #5; +void (string str) error = #6; +float (vector vec) vlen = #7; +string (entity ent) etos = #8; +float (string str) stof = #9; +string (...) strcat = #10; +float (string str1, string str2) strcmp = #11; +vector (vector vec) normalize = #12; +float (float val) sqrt = #13; +float (float val) floor = #14; +float (float val1, float val2) pow = #15; diff --git a/tests/noreturn.qc b/tests/noreturn.qc index ae614e7..4bd8d15 100644 --- a/tests/noreturn.qc +++ b/tests/noreturn.qc @@ -3,8 +3,7 @@ #endif void (...) print = #1; -string (float) ftos = #2; - +string (float val) ftos = #2; NORETURN void error(...) = #6; diff --git a/tests/paramomit.qc b/tests/paramomit.qc new file mode 100644 index 0000000..48d8d59 --- /dev/null +++ b/tests/paramomit.qc @@ -0,0 +1,3 @@ +void foo(float) { + +} diff --git a/tests/paramomit.tmpl b/tests/paramomit.tmpl new file mode 100644 index 0000000..50c5373 --- /dev/null +++ b/tests/paramomit.tmpl @@ -0,0 +1,4 @@ +I: paramomit.qc +D: test parameter omit +T: -fail +C: -std=fteqcc diff --git a/tests/pointlife.qc b/tests/pointlife.qc index 5225a7c..e32795a 100644 --- a/tests/pointlife.qc +++ b/tests/pointlife.qc @@ -1,7 +1,7 @@ var float foo = 0; void funcall() {} -void bar(string) {} +void bar(string str) {} void main(string str) { string pl; diff --git a/tests/typedefs.qc b/tests/typedefs.qc index e9bc13b..a518444 100644 --- a/tests/typedefs.qc +++ b/tests/typedefs.qc @@ -1,5 +1,5 @@ -typedef void(...) ptype; -typedef string(float) funcsf; +typedef void(...) ptype; +typedef string(float a) funcsf; ptype print = #1; funcsf ftos = #2; diff --git a/tests/varargs.qc b/tests/varargs.qc index 4b0d806..eceec4a 100644 --- a/tests/varargs.qc +++ b/tests/varargs.qc @@ -1,4 +1,4 @@ -void nbva(float a, string...count) { +void nbva(float a, ...count) { print("You gave me ", ftos(count), " additional parameters\n"); print("First: ", ...(0, string), "\n"); print("You chose: ", ...(a, string), "\n"); -- 2.39.2