From a873066466286217dc2caa83b9259eae21fae406 Mon Sep 17 00:00:00 2001 From: Arkshine Date: Sun, 17 Aug 2014 13:56:51 +0200 Subject: [PATCH] Compiler: Fix enum field size was not taken into account when implicitly passed to a function. Imported from Pawn 3.3.3930. Example: --- enum tag { member[32] } new var[tag]; foo(const string[], size = sizeof(string)) { // size returns 1 before fix, 32, after. } public plugin_init() { foo(var[member]); } --- --- compiler/libpc300/sc2.c | 2 +- compiler/libpc300/sc3.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/libpc300/sc2.c b/compiler/libpc300/sc2.c index 360d60a7..d5072cf4 100755 --- a/compiler/libpc300/sc2.c +++ b/compiler/libpc300/sc2.c @@ -2734,7 +2734,7 @@ SC_FUNC symbol *addvariable(const char *name,cell addr,int ident,int vclass,int * this special case. */ assert(vclass!=sGLOBAL || (sym=findglb(name))==NULL || (sym->usage & uDEFINE)==0 - || sym->ident==iFUNCTN && sym==curfunc); + || (sym->ident==iFUNCTN && sym==curfunc)); if (ident==iARRAY || ident==iREFARRAY) { symbol *parent=NULL,*top; diff --git a/compiler/libpc300/sc3.c b/compiler/libpc300/sc3.c index ee02b69e..a268a1b1 100755 --- a/compiler/libpc300/sc3.c +++ b/compiler/libpc300/sc3.c @@ -2047,7 +2047,7 @@ static int nesting=0; error(47); /* array sizes must match */ } /* if */ } /* if */ - if (lval.ident!=iARRAYCELL) { + if (lval.ident!=iARRAYCELL|| lval.constval>0) { /* save array size, for default values with uSIZEOF flag */ cell array_sz=lval.constval; assert(array_sz!=0);/* literal array must have a size */