From b876a6b213eb4fb8d821f4dba77079a3e7cb8917 Mon Sep 17 00:00:00 2001 From: acqn Date: Tue, 19 Dec 2023 19:30:50 +0800 Subject: [PATCH] Fixed cc65 exitcode when there are only preprocessor errors. --- src/cc65/main.c | 4 ++-- test/err/bug2312-pperror-only.c | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 test/err/bug2312-pperror-only.c diff --git a/src/cc65/main.c b/src/cc65/main.c index bef646cdd..7dc5417f6 100644 --- a/src/cc65/main.c +++ b/src/cc65/main.c @@ -1089,7 +1089,7 @@ int main (int argc, char* argv[]) Compile (InputFile); /* Create the output file if we didn't had any errors */ - if (PreprocessOnly == 0 && (ErrorCount == 0 || Debug)) { + if (PreprocessOnly == 0 && (GetTotalErrors () == 0 || Debug)) { /* Emit literals, do cleanup and optimizations */ FinishCompile (); @@ -1115,5 +1115,5 @@ int main (int argc, char* argv[]) DoneSegAddrSizes (); /* Return an apropriate exit code */ - return (ErrorCount > 0)? EXIT_FAILURE : EXIT_SUCCESS; + return (GetTotalErrors () > 0)? EXIT_FAILURE : EXIT_SUCCESS; } diff --git a/test/err/bug2312-pperror-only.c b/test/err/bug2312-pperror-only.c new file mode 100644 index 000000000..bdec33956 --- /dev/null +++ b/test/err/bug2312-pperror-only.c @@ -0,0 +1,8 @@ +/* Bug #2312 */ + +#error "Compiler should exit with failure" + +int main(void) +{ + return 0; +}