From 62c243f0a5da828da3bba37797bb696e3624849c Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 22 Nov 2014 12:23:57 -0800 Subject: [PATCH] Fix reading the wrong symbol name when throw argument errors. --- sourcepawn/compiler/sc1.cpp | 4 ++-- sourcepawn/compiler/tests/fail-default-args-in-public.sp | 1 + sourcepawn/compiler/tests/fail-default-args-in-public.txt | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 sourcepawn/compiler/tests/fail-default-args-in-public.sp create mode 100644 sourcepawn/compiler/tests/fail-default-args-in-public.txt diff --git a/sourcepawn/compiler/sc1.cpp b/sourcepawn/compiler/sc1.cpp index d8e5f037..f362b86b 100644 --- a/sourcepawn/compiler/sc1.cpp +++ b/sourcepawn/compiler/sc1.cpp @@ -5645,7 +5645,7 @@ static int declargs(symbol *sym, int chkshadow, const int *thistag) if (argcnt>=sMAXARGS) error(45); if (decl.name[0] == PUBLIC_CHAR) - error(56,name); /* function arguments cannot be public */ + error(56, decl.name); /* function arguments cannot be public */ if (decl.type.ident == iARRAY) decl.type.ident = iREFARRAY; @@ -5659,7 +5659,7 @@ static int declargs(symbol *sym, int chkshadow, const int *thistag) doarg(&decl,(argcnt+3)*sizeof(cell),fpublic,chkshadow,&arg); if ((sym->usage & uPUBLIC) && arg.hasdefault) - error(59,name); /* arguments of a public function may not have a default value */ + error(59, decl.name); /* arguments of a public function may not have a default value */ if ((sym->usage & uPROTOTYPED)==0) { /* redimension the argument list, add the entry */ diff --git a/sourcepawn/compiler/tests/fail-default-args-in-public.sp b/sourcepawn/compiler/tests/fail-default-args-in-public.sp new file mode 100644 index 00000000..97a39802 --- /dev/null +++ b/sourcepawn/compiler/tests/fail-default-args-in-public.sp @@ -0,0 +1 @@ +public x(param = 1) {} diff --git a/sourcepawn/compiler/tests/fail-default-args-in-public.txt b/sourcepawn/compiler/tests/fail-default-args-in-public.txt new file mode 100644 index 00000000..01947b24 --- /dev/null +++ b/sourcepawn/compiler/tests/fail-default-args-in-public.txt @@ -0,0 +1 @@ +(1) : error 059: function argument may not have a default value (variable "param")