diff options
author | Carl Worth <[email protected]> | 2010-07-20 16:44:03 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2010-07-20 17:01:12 -0700 |
commit | e1acbfca322c4ac720707ec8d3fda08fab65a30b (patch) | |
tree | 2ff0280eab03abc0c9c8655f050ea2ecb9567bdd /src/glsl/glcpp/tests | |
parent | 942ccc517012e360a7e30d3322331c8450dda022 (diff) |
glcpp: Avoid accidental token pasting in preprocessed result.
Consider this test case:
#define EMPTY
int foo = 1+EMPTY+4;
The expression should compile as the sequence of tokens 1, PLUS,
UNARY_POSITIVE, 4. But glcpp has been failing for this case since it
results in the string "1++4" which a compiler correctly sees as a
syntax error, (1, POST_INCREMENT, 4).
We fix this by changing any macro with an empty definition to result
in a single SPACE token rather than nothing. This then gives "1+ +4"
which compiles correctly.
This commit does touch up the two existing test cases which already
have empty macros, (to add the space to the expected result).
It also adds a new test case to exercise the above scenario.
Diffstat (limited to 'src/glsl/glcpp/tests')
4 files changed, 25 insertions, 2 deletions
diff --git a/src/glsl/glcpp/tests/008-define-empty.c.expected b/src/glsl/glcpp/tests/008-define-empty.c.expected index b28b04f6431..c0f53d75c71 100644 --- a/src/glsl/glcpp/tests/008-define-empty.c.expected +++ b/src/glsl/glcpp/tests/008-define-empty.c.expected @@ -1,3 +1,3 @@ - + diff --git a/src/glsl/glcpp/tests/011-define-func-empty.c.expected b/src/glsl/glcpp/tests/011-define-func-empty.c.expected index b28b04f6431..c0f53d75c71 100644 --- a/src/glsl/glcpp/tests/011-define-func-empty.c.expected +++ b/src/glsl/glcpp/tests/011-define-func-empty.c.expected @@ -1,3 +1,3 @@ - + diff --git a/src/glsl/glcpp/tests/068-accidental-pasting.c b/src/glsl/glcpp/tests/068-accidental-pasting.c new file mode 100644 index 00000000000..699ac5144e5 --- /dev/null +++ b/src/glsl/glcpp/tests/068-accidental-pasting.c @@ -0,0 +1,11 @@ +#define empty +<empty< +<empty= +>empty> +>empty= +=empty= +!empty= +&empty& +|empty| ++empty+ +-empty- diff --git a/src/glsl/glcpp/tests/068-accidental-pasting.c.expected b/src/glsl/glcpp/tests/068-accidental-pasting.c.expected new file mode 100644 index 00000000000..ce41cd6e524 --- /dev/null +++ b/src/glsl/glcpp/tests/068-accidental-pasting.c.expected @@ -0,0 +1,12 @@ + +< < +< = +> > +> = += = +! = +& & +| | ++ + +- - + |