Separated C preprocessor errors from other errors.

This commit is contained in:
acqn
2023-12-18 15:30:53 +08:00
parent 05aae60816
commit cd7c688dff
7 changed files with 91 additions and 30 deletions

View File

@@ -63,7 +63,8 @@ CUSTOMSOURCES = \
# exact error output is required
ERRORSOURCES = \
custom-reference-error.c \
bug1889-missing-identifier.c
bug1889-missing-identifier.c \
bug2312-preprocessor-error.c
SOURCES := $(filter-out $(CUSTOMSOURCES) $(ERRORSOURCES),$(wildcard *.c))

View File

@@ -0,0 +1,8 @@
/* Bug #2312 - Error recovery from preprocessor errors at the end of a declaration */
typedef int A; /* ';' consumption triggers PP below */
#define /* PP error during ';' consumption */
A f(void); /* Should be OK */
int A(void); /* Should be an error */

View File

@@ -0,0 +1,2 @@
bug2312-preprocessor-error.c:5: Error: Missing macro name
bug2312-preprocessor-error.c:8: Error: Redefinition of typedef 'A' as different kind of symbol

View File

@@ -13,7 +13,10 @@
and then "make" again to confirm
*/
short main(int argc, char* argv[])
typedef short return_t;
#error /* produce an error */
return_t main(int argc, char* argv[])
{
printf("%02x", 0x42); /* produce an error */
n = 0; /* produce an error */

View File

@@ -1,5 +1,6 @@
custom-reference-error.c:18: Error: Call to undeclared function 'printf'
custom-reference-error.c:19: Error: Undeclared identifier 'n'
custom-reference-error.c:21: Warning: Control reaches end of non-void function [-Wreturn-type]
custom-reference-error.c:21: Warning: Parameter 'argc' is never used
custom-reference-error.c:21: Warning: Parameter 'argv' is never used
custom-reference-error.c:17: Error: #error
custom-reference-error.c:21: Error: Call to undeclared function 'printf'
custom-reference-error.c:22: Error: Undeclared identifier 'n'
custom-reference-error.c:24: Warning: Control reaches end of non-void function [-Wreturn-type]
custom-reference-error.c:24: Warning: Parameter 'argc' is never used
custom-reference-error.c:24: Warning: Parameter 'argv' is never used