Commit Graph

131 Commits

Author SHA1 Message Date
Carl Worth
3d78f83cde Add expected file for 095-recursive-define test case.
It's clear enough that the current segmentation fault isn't what we
want. And it's also very easy to know what we do want here, (just
check with any functional C preprocessor such as "gcc -E").

Add the desired output as an expected file so that the test suite
gives useful output, (showing the omitted output and the segfault),
rather than just reporting "No such file" for the expected file.
2011-04-14 16:20:49 -07:00
Carl Worth
02d293c08e glcpp: Simplify calling convention of parser's active_list functions
These were all written as generic list functions, (accepting and returning
a list to act upon). But they were only ever used with parser->active as
the list. By simply accepting the parser itself, these functions can update
parser->active and now return nothing at all. This makes the code a bit
more compact.

And hopefully the code is no less readable since the functions are also
now renamed to have "_parser_active" in the name for better correlation
with nearby tests of the parser->active field.
2011-04-14 15:35:41 -07:00
Carl Worth
0b80f2d4c9 glcpp: Add --valgrind option to the glcpp-test utility
The common case for this test suite is to quickly test that everything
returns the correct results. In this case, the second run of the test
suite under valgrind was just annoying, (and the user would often
interrupt it).

Now, do what is wanted in the common case by default (just run the
test suite), and require a run with "glcpp-test --valgrind" in order
to test with valgrind.
2011-04-14 14:55:52 -07:00
Carl Worth
6affa4806a Add an expected file for 084-unbalanced-parentheses
The expected file here captures the current behavior of glcpp (which
is to generate an obscure "syntax error, unexpected $end" diagnostic
for this case).

It would certainly be better for glcpp to generate a nicer diagnostic,
(such as "missing closing parenthesis in function-like macro
definition" or so), but the current behavior is at least correct, and
expected. So we can make the test suite more useful by marking the
current behavior as expected.
2011-04-14 14:43:11 -07:00
Carl Worth
d3c6ed382d Add an expected file for 094-divide-by-zero-short-circuit
The expected file here captures the current behavior of glcpp (which
is to generate a division-by-zero error) for this case.

It's easy to argue that it should be short-circuiting the evaluation
and not generating the diagnostic (which happens to be what gcc does).
But it doesn't seem like we should force this behavior on our
pre-processor, (and, as always, the GLSL specification of the
pre-processor is too vague on this point).
2011-04-14 14:42:52 -07:00
Carl Worth
ea3b2560b1 Add an expected file for 093-divide-by-zero
This test is behaving just fine already---it's generating an informative
diagnostic, ("error: division by 0 in preprocessor directive"), so adding
this in the expected file makes things pass.
2011-04-14 14:29:34 -07:00
José Fonseca
12d17bcadf glsl/glcpp: Use stdio.h instead of unistd.h. 2011-03-04 12:53:14 +00:00
José Fonseca
f52660c3dc glsl: Define YY_NO_UNISTD_H on MSVC. 2011-03-04 12:49:55 +00:00
Kenneth Graunke
09e1bebc25 glcpp: Remove trailing contexts from #if rules.
These are now unnecessary.
2011-03-03 10:42:37 -08:00
Kenneth Graunke
f20656e944 glcpp: Rework lexer to use a SKIP state rather than REJECT.
Previously, the rule deleted by this commit was matched every single
time (being the longest match).  If not skipping, it used REJECT to
continue on to the actual correct rule.

The flex manual advises against using REJECT where possible, as it is
one of the most expensive lexer features.  So using it on every match
seems undesirable. Perhaps more importantly, it made it necessary for
the #if directive rules to contain a look-ahead pattern to make them
as long as the (now deleted) "skip the whole line" rule.

This patch introduces an exclusive start state, SKIP, to avoid REJECTs.
Each time the lexer is called, the code at the top of the rules section
will run, implicitly switching the state to the correct one.

Fixes piglit tests 16384-consecutive-chars.frag and
16385-consecutive-chars.frag.
2011-03-03 10:42:37 -08:00
Kenneth Graunke
b56f30c2b2 glcpp/tests: Update 063-comments.c.expected to match output.
The expected result has been out of sync with what glcpp produces for
some time; glcpp's actual result seems to be correct and is very close to
GCC's cpp.  Updating this will make it easier to catch regressions in
upcoming commits.
2011-03-03 10:42:37 -08:00
Kenneth Graunke
2e756f3d6f glsl: Remove unused glcpp/Makefile.am.
This is a remnant of when glsl2 lived in its own repository.
2011-03-02 15:25:49 -08:00
Ian Romanick
6dd0a2ed40 Add generated parser / lexer files to gitignore lists 2011-03-01 13:43:12 -08:00
Ian Romanick
cb48207e4b glcpp: Remove files generated by flex and bison from GIT 2011-03-01 13:43:12 -08:00
Ian Romanick
a0120e6e0f glcpp: regerated files
These should have been committed right after fd1252ab, but they were
missed.  Soon, we'll never have to do this again...
2011-02-11 15:44:19 -08:00
Chad Versace
fd1252ab67 glcpp: Raise error when modulus is zero
For example, this now raises an error:
   #define XXX 1 / 0

Fixes bug: https://bugs.freedesktop.org//show_bug.cgi?id=33507
Fixes Piglit test: spec/glsl-1.10/preprocessor/modulus-by-zero.vert

NOTE: This is a candidate for the 7.9 and 7.10 branches.
2011-02-02 10:19:51 -08:00
Brian Paul
a1f5c46d24 glsl: regerated files 2011-01-31 14:09:24 -07:00
Brian Paul
aacd07d623 glsl: make _token_list_is_empty_ignoring_space() static
To silence warning about missing prototype.
2011-01-31 14:09:24 -07:00
Kenneth Graunke
d3073f58c1 Convert everything from the talloc API to the ralloc API. 2011-01-31 10:17:09 -08:00
Carl Worth
2a18d1950c Revert "glcpp: Demote "macro redefined" from an error to a warning"
This reverts commit d3df641f0a.

The original commit had sat unpushed on my machine for months. By the
time I found it again, I had forgotten that we had decided not to use
this change after all, (the relevant test was removed long ago).
2011-01-29 08:21:05 +10:00
Carl Worth
d3df641f0a glcpp: Demote "macro redefined" from an error to a warning
The GLSL specification is vague here, (just says "as is standard for
C++"), though the C specifications seem quite clear that this should
be an error.

However, an existing piglit test (CorrectPreprocess11.frag) expects
this to be a warning, not an error, so we change this, and document in
README the deviation from the specification.
2011-01-28 15:16:36 +10:00
Chad Versace
39cad66a88 glsl: Refresh autogenerated parser files
For commits titled:
glcpp: Conditionally define macro GL_AMD_conservative_depth
glsl: Add support for AMD_conservative_depth to parser
2011-01-26 16:37:44 -08:00
Chad Versace
0423f24eb8 glcpp: Conditionally define macro GL_AMD_conservative_depth
Define macro GL_AMD_conservative_depth to 1 when its extension is
enabled.
2011-01-26 16:37:44 -08:00
Kenneth Graunke
0db3161036 glcpp: Regenerate parser files. 2011-01-21 15:41:19 -08:00
Kenneth Graunke
6ecee54a9a glcpp: Remove use of talloc reference counting.
We almost always want to simply steal; we only need to copy when copying
a token list (in which case we're already cloning stuff anyway).
2011-01-21 15:41:19 -08:00
Ian Romanick
a302d740bd glcpp: Refresh autogenerated lexer and parser files.
For the previous commit.
2011-01-10 17:38:56 -08:00
Ian Romanick
9ca5300b6e glcpp: Generate an error for division by zero
When GCC encounters a division by zero in a preprocessor directive, it
generates an error.  Since the GLSL spec says that the GLSL
preprocessor behaves like the C preprocessor, we should generate that
same error.

It's worth noting that I cannot find any text in the C99 spec that
says this should be an error.  The only text that I can find is line 5
on page 82 (section 6.5.5 Multiplicative Opertors), which says,

    "The result of the / operator is the quotient from the division of
    the first operand by the second; the result of the % operator is
    the remainder. In both operations, if the value of the second
    operand is zero, the behavior is undefined."

Fixes 093-divide-by-zero.c test and bugzilla #32831.

NOTE: This is a candidate for the 7.9 and 7.10 branches.
2011-01-10 17:37:51 -08:00
Chad Versace
4e09a786d2 glcpp: Regenerate glcpp-parse.c 2011-01-10 17:28:24 -08:00
Chad Versace
4fff52f1c9 glcpp: Fix segfault when validating macro redefinitions
In _token_list_equal_ignoring_space(token_list_t*, token_list_t*), add
a guard that prevents dereferncing a null token list.

This fixes test src/glsl/glcpp/tests/092-redefine-macro-error-2.c and
Bugzilla #32695.
2011-01-10 17:28:24 -08:00
Vinson Lee
5a3f31575b glcpp: Add test for recursive #define. 2011-01-04 16:39:19 -08:00
Vinson Lee
6530944b50 glcpp: Add division by zero test cases. 2011-01-04 13:18:19 -08:00
Vinson Lee
f3319561a4 glcpp: Add negative tests for redefintions with valueless macros. 2010-12-27 23:20:35 -08:00
Kenneth Graunke
bd74101aeb Refresh autogenerated glcpp parser. 2010-12-07 10:52:59 -08:00
Kenneth Graunke
800eed6765 glcpp: Don't emit SPACE tokens in conditional_tokens production.
Fixes glslparsertest defined-01.vert.

Reported-by: José Fonseca <jfonseca@vmware.com>
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
2010-12-07 10:52:36 -08:00
Kenneth Graunke
302fe4049c Regenerate glcpp parser. 2010-11-17 12:53:07 -08:00
Kenneth Graunke
d719bf8fb4 glsl: Unconditionally define GL_FRAGMENT_PRECISION_HIGH in ES2 shaders.
This is really supposed to be defined only if the driver supports highp
in the fragment shader - but all of our current ES2 implementations do.
So, just define it.  In the future, we'll need to add a flag to
gl_context and only define the macro if the flag is set.

"Fixes" freedesktop.org bug #31673.
2010-11-17 12:50:35 -08:00
Kenneth Graunke
bee901a1cf Refresh autogenerated glcpp parser. 2010-11-16 16:22:13 -08:00
Kenneth Graunke
3fb83038a0 glcpp: Define GL_FRAGMENT_PRECISION_HIGH if GLSL version >= 1.30.
Per section 4.5.4 of the GLSL 1.30 specification.
2010-11-16 16:22:12 -08:00
Benjamin Franzke
46c1970067 r600g: implement texture_get_handle (needed for eglExportDRMImageMESA) 2010-11-08 13:44:54 -05:00
Kenneth Graunke
94a36faed7 glcpp: Refresh autogenerated lexer file. 2010-10-21 00:13:33 -07:00
Kenneth Graunke
bd55ba568b glcpp: Return NEWLINE token for newlines inside multi-line comments.
This is necessary for the main compiler to get correct line numbers.
2010-10-21 00:13:33 -07:00
Ian Romanick
3322fbaf3b glsl: Slightly change the semantic of _LinkedShaders
Previously _LinkedShaders was a compact array of the linked shaders
for each shader stage.  Now it is arranged such that each slot,
indexed by the MESA_SHADER_* defines, refers to a specific shader
stage.  As a result, some slots will be NULL.  This makes things a
little more complex in the linker, but it simplifies things in other
places.

As a side effect _NumLinkedShaders is removed.

NOTE: This may be a candidate for the 7.9 branch.  If there are other
patches that get backported to 7.9 that use _LinkedShader, this patch
should be cherry picked also.
2010-10-14 17:16:59 -07:00
Ian Romanick
eafebed5bd glcpp: Regenerate files changes by previous commit 2010-10-08 14:21:22 -07:00
Ian Romanick
e0c9f67be5 glcpp: Add the define for ARB_explicit_attrib_location when present 2010-10-08 14:21:22 -07:00
Kenneth Graunke
48e789d71e glcpp: Fix build on non-GCC compilers. 2010-09-07 18:01:33 -07:00
Kenneth Graunke
7dcfc44b72 glsl: Define GL_ES preprocessor macro if API is OpenGL ES 2.0.
Also define it if #version 100 is encountered.
2010-09-07 17:30:37 -07:00
Brian Paul
1be5d1c887 glsl2: remove 'extern' keyword in .c file 2010-08-27 14:30:59 -06:00
Aras Pranckevicius
653ddaab26 glsl/mesa: fixes for MSVC
Signed-off-by: Brian Paul <brianp@vmware.com>
2010-08-25 09:21:10 -06:00
Chia-I Wu
bfd7c9ac22 glsl: Include main/core.h.
Make glsl include only main/core.h from core mesa.
2010-08-24 11:27:29 +08:00
Carl Worth
61f73fec53 glcpp: Make standalone preprocessor work with a tty as stdin
Previously glcpp would silently abort if it couldn't fstat the file being
read, (so it would work with stdin redirected from a file, but would not
work with stdin as a tty). The stat was so that glcpp could allocate
a buffer for the file content in a single call.

We now use talloc_realloc instead, (even if the fstat is
possible). This is theoretically less efficient, but quite irrelevant,
(particularly because the standalone preprocessor is used only for
testing).
2010-08-23 10:48:10 -07:00