The change from #2495 didn't take into account that recursive calls to main()

are legal in C. With the changes from #2495, such calls will usually crash the
machine. But recursive calls to main() are rare and on the 6502 every byte
saved is precious. So this change limits the effect of #2495 to cc65 mode and
at the same time disallows recursive calls to main() in this mode. If
recursive calls to main() are actually required, the code must be compiled in
c89 or c99 mode.
This commit is contained in:
Kugel Fuhr
2024-09-02 10:39:42 +02:00
parent 5e5dd1d6c4
commit cd4357057f
8 changed files with 54 additions and 19 deletions

View File

@@ -22,6 +22,5 @@ return_t main(int argc, char* argv[])
n = 0; /* produce an error */
/* produce a warning */
}
int arr[main(0, 0)]; /* produce an error */
int b = 0;
int arr[b]; /* produce an error */

View File

@@ -28,6 +28,8 @@ struct S {
} \
} while(0);
void func() { }
int main()
{
int a;
@@ -60,7 +62,7 @@ int main()
TEST_NON_NULL(((struct S*)&a)->a)
/* Non-null pointer obtained with cast and -> */
TEST_NON_NULL(((struct S*)&main)->a)
TEST_NON_NULL(((struct S*)&func)->a)
if (failures != 0)
{