mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-28 10:20:09 +01:00
glsl/glcpp: Add testing for EOF sans newline (and fix for <DEFINE>, <COMMENT>)
The glcpp implementation has long had code to support a file that ends without a final newline. But we didn't have a "make check" test for this. Additionally, the <EOF> action was restricted only to the <INITIAL> state so it would fail to get invoked if the EOF was encountered in the <COMMENT> or the <DEFINE> case. Neither of these was a bug, per se, since EOF in either of these cases is an error anyway, (either "unterminated comment" or "missing macro name for #define"). But with the new explicit support for these cases, we not generate clean error messages in these cases, (rather than "unexpected $end" from before). Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
This commit is contained in:
parent
21dda50549
commit
5dbdc341e8
7 changed files with 13 additions and 2 deletions
|
|
@ -398,8 +398,11 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
|
|||
return NEWLINE;
|
||||
}
|
||||
|
||||
/* Handle missing newline at EOF. */
|
||||
<INITIAL><<EOF>> {
|
||||
<INITIAL,COMMENT,DEFINE><<EOF>> {
|
||||
if (YY_START == COMMENT)
|
||||
glcpp_error(yylloc, yyextra, "Unterminated comment");
|
||||
if (YY_START == DEFINE)
|
||||
glcpp_error(yylloc, yyextra, "#define without macro name");
|
||||
BEGIN DONE; /* Don't keep matching this rule forever. */
|
||||
yyextra->lexing_directive = 0;
|
||||
return NEWLINE;
|
||||
|
|
|
|||
1
src/glsl/glcpp/tests/131-eof-without-newline.c
Normal file
1
src/glsl/glcpp/tests/131-eof-without-newline.c
Normal file
|
|
@ -0,0 +1 @@
|
|||
this file ends with no newline
|
||||
1
src/glsl/glcpp/tests/131-eof-without-newline.c.expected
Normal file
1
src/glsl/glcpp/tests/131-eof-without-newline.c.expected
Normal file
|
|
@ -0,0 +1 @@
|
|||
this file ends with no newline
|
||||
1
src/glsl/glcpp/tests/132-eof-without-newline-define.c
Normal file
1
src/glsl/glcpp/tests/132-eof-without-newline-define.c
Normal file
|
|
@ -0,0 +1 @@
|
|||
#define
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
0:1(2): preprocessor error: #define without macro name
|
||||
0:1(2): preprocessor error: syntax error, unexpected NEWLINE, expecting FUNC_IDENTIFIER or OBJ_IDENTIFIER
|
||||
1
src/glsl/glcpp/tests/133-eof-without-newline-comment.c
Normal file
1
src/glsl/glcpp/tests/133-eof-without-newline-comment.c
Normal file
|
|
@ -0,0 +1 @@
|
|||
This file ends with no newline within a comment /*
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
0:1(52): preprocessor error: Unterminated comment
|
||||
This file ends with no newline within a comment
|
||||
Loading…
Add table
Reference in a new issue