Commit Graph

151 Commits

Author SHA1 Message Date
Carl Worth
6b9e7b034c glccp: Regenerate glcpp-parse.c
Due to a recent change to glcpp-parse.y.
2010-08-11 14:38:04 -07:00
Carl Worth
253cad3f42 glcpp: Add an explicit diagnostic for #if with no expression.
This is more clear than the previously-generated diagnostic which was
something confusing like "enexpected newline".

This change makse test 080-if-witout-expression.c now pass.
2010-08-11 14:38:04 -07:00
Carl Worth
624dd585c7 glcpp: Reword diagnostic for #elif with no expression
Rather than telling the user what to fix, the standard convention is to
describe what the detected problem is. With this change, test
081-elif-without-expression now passes.
2010-08-11 14:38:03 -07:00
Carl Worth
cb5ea0c79b glcpp: Add several tests for diagnostics.
Which are proving to be useful since some of these tests are not yet
acting as desired, (in particular, the unterminated if test is not
generating any diagnostic).
2010-08-11 14:38:03 -07:00
Carl Worth
5a6285cc86 glcpp: Regenerate glcpp-lex.c
After a recent change to glcpp-lex.l
2010-08-11 14:38:03 -07:00
Carl Worth
bc64b89808 glcpp: Initialize line and column numbers to 1, not 0.
Error messages make more sense this way since the convention is for
the first line of a file to be numbered from 1, rather than 0.
2010-08-11 14:38:03 -07:00
Carl Worth
2bcff4c879 glcpp-test: Capture the stderr output of the preprocessor.
This allows writing tests that verify diagnostics from the preprocessor.
2010-08-11 14:38:03 -07:00
Brian Paul
d1dda951c8 glsl2: move declarations before code 2010-08-11 15:06:12 -06:00
Carl Worth
8485f4d9aa glcpp: Clean up intermediate file when test suite is interrupted.
The glcpp-test script was leaving around bogus *.valgrind-errors files if
a valgrind test was interrupted.
2010-08-11 12:46:16 -07:00
Carl Worth
764e096647 glcpp: Regenerate glcpp-parse.c
After a recent change to glcpp-parse.y
2010-08-11 12:45:55 -07:00
Carl Worth
48ba058e7a glcpp: Additional fixes for not evaluating skipped #if/#elif expressions.
This adds a couple of test cases to expand our coverage of invalid #if and
being skipped, (either by being nested inside an #if/#elif that evaluates to
zero or by being after an #if/#elif that evaluates to non-zero).
2010-08-11 12:43:44 -07:00
Kenneth Graunke
298a6fcdde glcpp/tests: Commit forgotten file 074-elif-undef.c.expected. 2010-08-10 19:18:44 -07:00
Carl Worth
9b7fd2099f glcpp: Discard output of cmp when running the test suite.
We're already using the return-value of cmp to print either PASS or
FAIL and in the case of failure, we're subsequently running and
showing the output of diff. So any warnings/errors from cmp itself are
not actually needed, and can be quite confusing.
2010-08-10 18:27:31 -07:00
Carl Worth
4f9a64407c glcpp: Fix expected result for the 064-version.c test.
Commit d4a04f3155 caused this test case
to produce an additional blank line, which is otherwise harmless, but
does need to be reflected in the .expected file for the test to pass.
2010-08-10 18:25:30 -07:00
Carl Worth
e29cd39125 glcpp: Regnerate glcpp-parse.c and glcpp-parse.h
After making a minor change to the .y file.
2010-08-10 16:59:20 -07:00
Carl Worth
485f84d366 glcpp: Initialize location structure at beginning of parse.
Since we have a custom structure for YYLTYPE locations, we need to use
an %initial-action directive to avoid triggering use of uninitialized
memory when, for example, printing error messages.

We apparently don't yet have a test case that allowed valgrind to find
this bug for us, but valgrind found a similar problem in the other
parser, so we fix this one as well.
2010-08-10 16:58:28 -07:00
Kenneth Graunke
f4239872c9 glcpp: Ignore #if and #elif expressions when skipping.
Fixes glcpp test cases 073 and 074, as well as piglit test
xonotic-vs-generic-diffuse.vert.
2010-08-04 23:37:19 -07:00
Kenneth Graunke
d65135a766 glcpp/tests: Add a corollary to testcase 073 for testing #elif. 2010-08-04 23:37:19 -07:00
Kenneth Graunke
c52b2be166 glcpp/tests: Fix 073-if-in-ifdef.c to use #ifdef, not #if.
The original intention was to use #ifdef.
2010-08-04 23:37:19 -07:00
Kenneth Graunke
16b4eed59a glcpp: Refactor HASH_IF and HASH_ELIF expansion to reuse code. 2010-08-04 23:37:18 -07:00
Kenneth Graunke
0ef79a5f11 glcpp: Refresh autogenerated lexer and parser. 2010-08-04 15:57:20 -07:00
Kenneth Graunke
1ffc1cd861 glcpp: Remove xtalloc wrappers in favor of plain talloc.
Calling exit() on a memory failure probably made sense for the
standalone preprocessor, but doesn't seem too appealing as part of
the GL library.  Also, we don't use it in the main compiler.
2010-08-04 15:57:20 -07:00
Aras Pranckevicius
31747155ea glsl2: Give the path within src/mesa/ for headers instead of relying on -I. 2010-08-02 10:59:46 -07:00
Eric Anholt
93b10bd353 glcpp: Add a testcase for the failure in compiling xonotic's shader.
gcc and mesa master agree that this is OK.
2010-08-01 11:40:07 -07:00
Kenneth Graunke
805cbf3922 glcpp: Don't look for backslashes before the beginning of the string.
Fixes a valgrind error.
2010-07-30 13:26:14 -07:00
Eric Anholt
d6942460ce glsl2: Actually fix glsl-version-define. 2010-07-28 17:36:07 -07:00
Eric Anholt
d4a04f3155 glcpp: Add __VERSION__ define to the current language version.
Fixes:
glsl-version-define
glsl-version-define-110
glsl-version-define-120
2010-07-28 17:32:39 -07:00
Eric Anholt
8605c297cf glcpp: Print integer tokens as decimal, not hex. 2010-07-28 17:32:11 -07:00
Eric Anholt
0c7b37c836 glsl2: Add the define for ARB_fragment_coord_conventions when present.
Fixes:
glsl-arb-fragment-coord-conventions-define
2010-07-28 15:00:29 -07:00
Carl Worth
667173e362 glcpp: Add generated source files.
This is now consistent with other usage of flex/bison througout mesa,
(which is that these generated files are added to source control so
that the build system does not require external tools like flex/bison
for non-developers).
2010-07-28 13:48:32 -07:00
Carl Worth
279cc22dbc glcpp: Add expected output for a recently-added test.
I simply forgot to add this file when adding the test case originally.
2010-07-28 13:48:32 -07:00
Carl Worth
efef950f39 glcpp: Explicitly expect 0 shift/reduce conflicts.
The "%expect 0" construct will make bison emit an error if any future
changes to the grammar introduce shift/reduce conflicts, (without also
increasing the number after "%expect").
2010-07-28 11:10:52 -07:00
Carl Worth
2233d10442 glcpp: Remove 2 shift/reduce conflicts from the grammar.
Since we have productions to turn "defined FOO" and "defined ( FOO )"
into a conditional_token we don't need to list DEFINED as an operator
as well. Doing so just introduces the shift/reduce ambiguity with no
benefit.
2010-07-28 11:07:46 -07:00
Carl Worth
fbe4240626 glcpp: Fix function-like macros with an argument used multiple times.
It's really hard to believe that this case has been broken, but apparently
no test previously exercised it. So this commit adds such a test and fixes
it by making a copy of the argument token-list before expanding it.

This fix causes the following glean tests to now pass:

	glsl1-Preprocessor test 6 (#if 0, #define macro)
	glsl1-Preprocessor test 7 (multi-line #define)
2010-07-22 16:38:12 -07:00
Carl Worth
a0cfe8c440 glsl: Fix missing initialization of yylloc.source
In both the preprocessor and in the compiler proper, we use a custom
yyltype struct to allow tracking the source-string number in addition
to line and column. However, we were previously relying on bison's
default initialization of the yyltype struct which of course is not
aware of the source field and leaves it uninitialized.

We fix this by defining our own YYLLOC_DEFAULT macro expanding on the
default version (as appears in the bison manual) and adding
initialization of yylloc.source.
2010-07-21 13:52:33 -07:00
Carl Worth
e1acbfca32 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.
2010-07-20 17:01:12 -07:00
Carl Worth
942ccc5170 glcpp: Add missing include in xtalloc.c
Without this, the compiler was legitimately complaining about missing
declarations for all of the functions being defined here.
2010-07-20 17:01:12 -07:00
Carl Worth
d80dcaf427 glcpp: Add static keyword to several functions in the parser.
This quiets warnings about missing declarations otherwise.
2010-07-20 17:01:11 -07:00
Carl Worth
fb90560744 glcpp: Avoid warnings in generated flex code.
We define the YY_NO_INPUT macro to avoid one needless function being
generated.

for the other needless functions, (yyunput and yy_top_state), we add a
new UNREACHABLE start condition and call these functions from an
action there. This doesn't change functionality at all, (since we
never enter the UNREACHABLE start condition), but makes the compiler
stop complaining about these two functions being defined but not used.
2010-07-20 17:01:11 -07:00
Carl Worth
a9bb4bcde3 glcpp-lex: Declare some generated functions to eliminate compiler warnings.
It's really a bug in flex that these functions are generated with neither
a declaration nor the 'static' keyword, but we can at least avoid the
warnings this way.
2010-07-20 17:01:11 -07:00
Carl Worth
1d7e03e48e glcpp: Fix support for nested #ifdef and nested #ifndef
Previously, if the outer #ifdef/#ifndef evaluated to false, the inner
directive would not be parsed correctly, (the identifier as the subject
of the #ifdef/#ifndef would inadvertently be skipped along with the other
content correctly being skipped).

We fix this by setting the lexing_if state in each case here.

We also add a new test to the test suite to ensure that this case is tested.
2010-07-20 17:01:11 -07:00
Carl Worth
17f9beb6c3 glcpp: Support #if(expression) with no intervening space.
And add a test case to ensure that this works.
2010-07-20 17:01:11 -07:00
Carl Worth
61ebc01dfe glcpp: Fix use-after-free error from #undef directive.
By taking advantage of the recently-added hash_table_remove function.

With this change, all existing tests are now valgrind-clean.
2010-07-20 17:01:11 -07:00
Carl Worth
d1500f8a19 glcpp: Make test suite test for valgrind cleanliness.
As it turns out, 4 of our current tests are not valgrind clean,
(use after free errors or so), so this will be helpful for
investigating and fixing those.
2010-07-20 17:01:11 -07:00
Carl Worth
3a530b8ef6 glcpp: Make test suite report final count of passed/total tests.
And report PASS or FAIL for each test along the way as well.
2010-07-20 17:01:11 -07:00
Carl Worth
f15e27ec1d glcpp: Delete copies of hash_table.c, hash_table.h, and other headers.
These were only ever intended to exist in the original, standalone
implementation of glcpp, (with the idea of dropping them as soon as
the code moved into mesa). The current build system wasn't compiling
this C file, but the presence of the header files could cause problems
if the two copies diverge in the future.

We head those problems off by deleting al of these redundant files.
2010-07-20 17:01:11 -07:00
Kenneth Graunke
388ab9fa6b glsl2: Initialize yylineno and yycolumn so line numbers are sane. 2010-07-07 12:41:26 -07:00
Kenneth Graunke
7e908a6a27 glcpp: Add #error support. 2010-07-02 18:03:58 -07:00
Ian Romanick
06143ea094 glsl2: Conditionally define preprocessor tokens for optional extensions
The only optional extension currently supported by the compiler is
GL_EXT_texture_array.
2010-07-01 20:40:08 -07:00
Ian Romanick
2d12236117 glsl2: Define preprocessor tokens for extensions
Currently only GL_ARB_draw_buffers and GL_ARB_texture_rectangle are
defined because those extensions are always enabled.  This make
tex_rect-03.frag pass.
2010-07-01 20:40:08 -07:00