diff --git a/sourcepawn/compiler/sc3.cpp b/sourcepawn/compiler/sc3.cpp index 90aa2430..c8584e87 100644 --- a/sourcepawn/compiler/sc3.cpp +++ b/sourcepawn/compiler/sc3.cpp @@ -1702,7 +1702,7 @@ static int hier2(value *lval) lval->constval=array_levelsize(sym,level); } if (lval->constval==0 && strchr((char *)lptr,PREPROC_TERM)==NULL) - error(224,st); /* indeterminate array size in "sizeof" expression */ + error(163,st); /* indeterminate array size in "sizeof" expression */ } /* if */ ldconst(lval->constval,sPRI); while (paranthese--) @@ -1756,7 +1756,7 @@ static int hier2(value *lval) lval->constval=array_levelsize(sym,level); } if (lval->constval==0 && strchr((char *)lptr,PREPROC_TERM)==NULL) - error(224,st); /* indeterminate array size in "sizeof" expression */ + error(163,st); /* indeterminate array size in "sizeof" expression */ } /* if */ ldconst(lval->constval,sPRI); while (paranthese--) @@ -2890,7 +2890,7 @@ static int nesting=0; if (asz!=NULL) { array_sz=asz->value; if (array_sz==0) - error(224,arg[argidx].name); /* indeterminate array size in "sizeof" expression */ + error(163,arg[argidx].name); /* indeterminate array size in "sizeof" expression */ } else { array_sz=1; } /* if */ diff --git a/sourcepawn/compiler/sc5-in.scp b/sourcepawn/compiler/sc5-in.scp index a34d7b30..ddc69650 100644 --- a/sourcepawn/compiler/sc5-in.scp +++ b/sourcepawn/compiler/sc5-in.scp @@ -206,6 +206,7 @@ static const char *errmsg[] = { /*160*/ "brackets in between type and variable name indicate a dynamic-size array, but a fixed-size initializer was given\n", /*161*/ "brackets after variable name indicate a fixed-size array, but a dynamic size was given - did you mean to use 'new %s[size]' syntax?\n", /*162*/ "cannot create dynamic arrays in global scope - did you mean to create a fixed-length array with brackets after the variable name?\n", +/*163*/ "indeterminate array size in \"sizeof\" expression (symbol \"%s\")\n", #else "\315e\306\227\266k\217:\235\277bu\201fo\220\204\223\012", "\202l\224\250s\205g\346\356e\233\201(\243\315\214\267\202) \253 f\255low ea\305 \042c\353e\042\012", @@ -429,7 +430,7 @@ static const char *warnmsg[] = { /*221*/ "label name \"%s\" shadows tag name\n", /*222*/ "number of digits exceeds rational number precision\n", /*223*/ "redundant \"sizeof\": argument size is always 1 (symbol \"%s\")\n", -/*224*/ "indeterminate array size in \"sizeof\" expression (symbol \"%s\")\n", +/*224*/ "unused\n", /*225*/ "unreachable code\n", /*226*/ "a variable is assigned to itself (symbol \"%s\")\n", /*227*/ "more initializers than enum fields\n", diff --git a/sourcepawn/compiler/tests/fail-indeterminate-string-literal.sp b/sourcepawn/compiler/tests/fail-indeterminate-string-literal.sp new file mode 100644 index 00000000..27bb31ea --- /dev/null +++ b/sourcepawn/compiler/tests/fail-indeterminate-string-literal.sp @@ -0,0 +1,8 @@ +native print(const char[] str); +native printnum(num); + +public main() +{ + char[] egg = "!\n"; + return sizeof(egg); +} diff --git a/sourcepawn/compiler/tests/fail-indeterminate-string-literal.txt b/sourcepawn/compiler/tests/fail-indeterminate-string-literal.txt new file mode 100644 index 00000000..ac9a565b --- /dev/null +++ b/sourcepawn/compiler/tests/fail-indeterminate-string-literal.txt @@ -0,0 +1 @@ +(7) : error 163: indeterminate array size in "sizeof" expression (symbol "egg")