From 1f51393e26ddc13c0b5d44eabfb224b0c005c16e Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 20 Aug 2014 00:26:09 -0700 Subject: [PATCH] Fix typedefs not fixing string sizes (bug 6220). --- sourcepawn/compiler/sc1.c | 3 +++ .../compiler/tests/ok-typedef-func-chars.sp | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 sourcepawn/compiler/tests/ok-typedef-func-chars.sp diff --git a/sourcepawn/compiler/sc1.c b/sourcepawn/compiler/sc1.c index 154e33c4..e152c5c9 100644 --- a/sourcepawn/compiler/sc1.c +++ b/sourcepawn/compiler/sc1.c @@ -4223,6 +4223,9 @@ static void parse_function_type(functag_t *type) continue; } + // Account for strings. + fix_char_size(&decl); + funcarg_t *arg = &type->args[type->argcount++]; arg->tagcount = 1; arg->tags[0] = decl.type.tag; diff --git a/sourcepawn/compiler/tests/ok-typedef-func-chars.sp b/sourcepawn/compiler/tests/ok-typedef-func-chars.sp new file mode 100644 index 00000000..36f8753c --- /dev/null +++ b/sourcepawn/compiler/tests/ok-typedef-func-chars.sp @@ -0,0 +1,26 @@ +enum Action: {} +functag public Action:OldFuncTag( String:someString[128] ); +typedef NewFuncTag = function Action ( char someString[128] ); + +native UseOldFuncTag( OldFuncTag func ); +native UseNewFuncTag( NewFuncTag func ); + +public OnPluginStart() +{ + // fine + UseOldFuncTag( MyOldFunc ); + // also fine + UseOldFuncTag( MyNewFunc ); + + // error 100: function prototypes do not match + UseNewFuncTag( MyOldFunc ); + // error 100: function prototypes do not match + UseNewFuncTag( MyNewFunc ); +} + +public Action:MyOldFunc( String:someString[128] ) +{ +} +public Action MyNewFunc( char someString[128] ) +{ +}