ref: afa1694d36865e5f2d5858e641c573502edaef92
parent: dbb2ca15669b9542a46f2232ce74c3f95afd2902
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sat Jul 18 05:08:28 EDT 2015
Fix #line The validation of the fields in #line were incorrect, and the last token was not consumed, generating an error in cpp() due to garbage at the end of the line.
--- a/cc1/cpp.c
+++ b/cc1/cpp.c
@@ -409,15 +409,14 @@
static void
line(void)
{
- Type *tp;
long n;
+ char *endp;
if (cppoff)
return;
- if ((n = strtol(input->p, &input->p, 10)) <= 0 || n > USHRT_MAX)
- error("first parameter of #line is not a positive integer");
- if (yytoken != CONSTANT || yylval.sym->type != inttype)
+ n = strtol(yytext, &endp, 10);
+ if (n <= 0 || n > USHRT_MAX || *endp != '\0')
error("first parameter of #line is not a positive integer");
input->nline = yylval.sym->u.i;
@@ -425,11 +424,11 @@
if (yytoken == EOFTOK)
return;
- tp = yylval.sym->type;
- if (yytoken != CONSTANT || tp->op != ARY && tp->type != chartype)
+ if (*yytext != '\"'|| yylen == 1)
error("second parameter of #line is not a valid filename");
free(input->fname);
input->fname = xstrdup(yylval.sym->u.s);
+ next();
}
static void