diff options
author | Carl Worth <[email protected]> | 2014-07-01 17:40:28 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2014-08-07 16:08:28 -0700 |
commit | a196ab1f8aacf657e591a0a15c80c3f37b9496b0 (patch) | |
tree | 3ccc4e58c34408990b44f6c6ffa3ccbfa2c57500 /src/glsl/glcpp/tests | |
parent | b6ab52b7f941b689753d4b9af7d58083e6917fd6 (diff) |
glsl/glcpp: Add explicit error for "#define without macro name"
Previously, glcpp would emit an error like this if <EOF> happened to occur
immediately after the "#define", but in general would just get confused,
(leading to un-helpful error messages).
To fix things to generate a clean error message, we do a few things:
1. Don't require horizontal whitespace immediately after #define
2. Add a production for the error case, (DEFINE_TOKEN followed
immediately by a NEWLINE token).
3. Make the lexer reset to the <INITIAL> state after every NEWLINE.
This 3rd point prevents the lexer from getting so confused and generating
further spurious errors in the file because it was stuck in the <DEFINE> start
condition.
We also drop the similar error message from the <EOF> rule since the
newly-added rule will have already printed the error message.
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/glsl/glcpp/tests')
-rw-r--r-- | src/glsl/glcpp/tests/132-eof-without-newline-define.c.expected | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/glsl/glcpp/tests/132-eof-without-newline-define.c.expected b/src/glsl/glcpp/tests/132-eof-without-newline-define.c.expected index a3ace0f3966..341e5e2aa67 100644 --- a/src/glsl/glcpp/tests/132-eof-without-newline-define.c.expected +++ b/src/glsl/glcpp/tests/132-eof-without-newline-define.c.expected @@ -1,2 +1 @@ -0:1(2): preprocessor error: #define without macro name -0:1(2): preprocessor error: syntax error, unexpected NEWLINE, expecting FUNC_IDENTIFIER or OBJ_IDENTIFIER +0:1(1): preprocessor error: #define without macro name |