commit 8b81076cf27406237fb348e5cd30eaa900572bca
parent b0361eb8e544233e02128d5c2b7a7f40afbd15a2
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 16 Mar 2022 20:15:33 +0100
cpp: Add null preprocesor clause
A preprocessor line containing only a new line is considered a null
preprocessor clause and it must be ignored.
Diffstat:
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/cmd/cc/cc1/cpp.c b/src/cmd/cc/cc1/cpp.c
@@ -783,11 +783,14 @@ cpp(void)
next();
namespace = NS_IDEN;
+ if (yytoken == '\n')
+ goto ret;
+
for (bp = clauses; bp->token && bp->token != yytoken; ++bp)
;
if (!bp->token) {
errorp("incorrect preprocessor directive '%s'", yytext);
- goto error;
+ goto ret;
}
DBG("CPP %s", yytext);
@@ -805,7 +808,7 @@ cpp(void)
if (yytoken != '\n' && !cppoff && bp->token != INCLUDE)
errorp("trailing characters after preprocessor directive");
-error:
+ret:
disescape = 0;
disexpand = 0;
lexmode = CCMODE;