When built with PAWN_CELL_SIZE==32 cellmin anx cellmax were set
to LONG_MIN anx LONG_MAX respectively, but long is 64 bits wide
on 64-bit Linux systems (as opposed to Win64).
Fixes#17.
This fixes the same coding mistake as in the previous commit (4d2c600):
"sym->name!=NULL" should be "sym!=NULL" as sym->name can't be NULL.
--------- test code --------
main() {
if ("string") {}
}
----- end of test code -----
This patch fixes a bug in commit d23e03e "Allow trailing comma in array
initializers" where initarray() did an extra loop iteration hoping that
initvector() would fail nicely and ultimately inserted an extra cell
into the literal queue.
--------- test code --------
native printf(const format[], ...);
new const a[][] = {
{"hello"},
{"world"}
};
main() {
printf("%s", a[0]); // hello
printf("%d", sizeof(a)); // 2
printf("%d", sizeof(a[])); // 6
printf("%d", sizeof(a[][])); // 1
}
----- end of test code -----
The compiler now has a new command-line option (-Z) that toggles
between normal mode and "compatibility" mode.
When this mode is on the compiler attempts to be compatible with
the current SA-MP compiler, which allows compiling old SA-MP scripts
that would not compile otherwise and at the same time benefiting
from new features and bug fixes.
In particular, this allows compiling code that relies on the auto
generated #include guard symbols (_inc_filename).
And in case you're wondering, the Z in "-Z" does not stand for "Zeex",
it just means "a letter that is unlikely to be ever taken by another
option".
This closes#23.
It is allowed for symbol names to be up to sNAMEMAX characters but
the assert() restricted them to sNAMEMAX-1 characters, so it would
fail for any long enough name.
Ran across this investigating #21.
This patch introduces a new built-in constant called "__line" that is set
to the current line number during compile time. I've taken the code from
Pawn 4.0 though I'm pretty sure it was implemented prior to 4.0 as I've
seen __line mentioned in the language documentation for 3.x.
When applied to a function #pragma naked merely disables the "should return
a value" warning for the function. It's intended to be used with functions
that return a value via #emit instead of the normal return statement.
This pragma works only on function definitions, not declarations. It's also
pretty stupid - the function may be defined way after this directive and it
won't stop on things coming in between.
For example, here all declarations between #pragma naked and f() are
effectively ignored:
#pragma naked
new x; // ignored
forward g(); // ignored
native n(); // ignored
f() {
// f() becomes naked
}
Note that #pragma naked does not affect generated code in any way, unlike
e.g. __declspec(naked) or __attribute__((naked)) in C/C++ where the compiler
omits the code for the prolog and epilog.
Make the assembler fail with a fatal error 104 "invalid assembler instruction"
if met an unknown instruction. It won't tell a correct line number though.
This hopefully fixes a bug where code for a custom assignment operator
wasn't being generated because the compiler thought that it's not used
but it still generated a call (which resulting in infinite recursion).
It happened only if some function returned a tagged result and wasn't
forwarded before its first use. Interestingly the compiler didn't issue
a reparse when it encountered the forward declaration and no warning
was printed. Perhaps the authors forgot to do this when they were adding
the forward syntax (it certainly was added after what is now called
"old-style prototypes").
See 8) here: http://forum.sa-mp.com/showthread.php?t=355877
--------- test code --------
#include <a_samp>
_:operator=(Taggg:a)
{
return _:a + 5;
}
main()
{
new a = d();
printf("%d", a);
}
forward Taggg:d();
Taggg:d()
{
return Taggg:5;
}
----- end of test code -----
This fixes a bug where returning a string from a variadic function caused
an invalid memory access error during runtime. It seems like they forgot
to update existing string return code for variadic functions.
See 11) here: http://forum.sa-mp.com/showthread.php?t=355877
--------- test code --------
native print(const s[]);
stock f(...)
{
new a, b, c;
new str[] = "hello";
return str;
}
main() {
print(f(1, 2, 3));
}
----- end of test code -----
This fixes a crash during compile-time when returning a string or array
literal from a function. Now the compiler will give an error instead.
See 1) here: http://forum.sa-mp.com/showthread.php?t=355877
--------- test code --------
native use(...);
return_string() {
new string[] = "string";
return string;
}
return_string_literal() {
return "string"; // error 029: invalid expression, assumed zero
}
return_number() {
return 0;
}
main() {
new n = return_number(); // OK
new s[100];
s = return_string(); // OK
s = return_string_literal(); // error 033: array must be indexed (variable "s")
use(n, s);
}
----- end of test code -----