summaryrefslogtreecommitdiffstats
path: root/src/glsl/glcpp/glcpp-parse.y
Commit message (Collapse)AuthorAgeFilesLines
* glcpp: Raise error when modulus is zeroChad Versace2011-02-021-1/+6
| | | | | | | | | | 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.
* glsl: make _token_list_is_empty_ignoring_space() staticBrian Paul2011-01-311-1/+1
| | | | To silence warning about missing prototype.
* Convert everything from the talloc API to the ralloc API.Kenneth Graunke2011-01-311-75/+76
|
* Revert "glcpp: Demote "macro redefined" from an error to a warning"Carl Worth2011-01-291-4/+4
| | | | | | | | This reverts commit d3df641f0aba99b0b65ecd4d9b06798bca090a29. 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).
* glcpp: Demote "macro redefined" from an error to a warningCarl Worth2011-01-281-4/+4
| | | | | | | | | | 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.
* glcpp: Conditionally define macro GL_AMD_conservative_depthChad Versace2011-01-261-0/+2
| | | | | Define macro GL_AMD_conservative_depth to 1 when its extension is enabled.
* glcpp: Remove use of talloc reference counting.Kenneth Graunke2011-01-211-13/+7
| | | | | 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).
* glcpp: Generate an error for division by zeroIan Romanick2011-01-101-1/+6
| | | | | | | | | | | | | | | | | | | | 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.
* glcpp: Fix segfault when validating macro redefinitionsChad Versace2011-01-101-0/+21
| | | | | | | | 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.
* glcpp: Don't emit SPACE tokens in conditional_tokens production.Kenneth Graunke2010-12-071-1/+0
| | | | | | | | Fixes glslparsertest defined-01.vert. Reported-by: José Fonseca <[email protected]> Signed-off-by: Kenneth Graunke <[email protected]> Acked-by: Carl Worth <[email protected]>
* glsl: Unconditionally define GL_FRAGMENT_PRECISION_HIGH in ES2 shaders.Kenneth Graunke2010-11-171-1/+6
| | | | | | | | | 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.
* glcpp: Define GL_FRAGMENT_PRECISION_HIGH if GLSL version >= 1.30.Kenneth Graunke2010-11-161-0/+3
| | | | Per section 4.5.4 of the GLSL 1.30 specification.
* glcpp: Add the define for ARB_explicit_attrib_location when presentIan Romanick2010-10-081-0/+3
|
* glcpp: Fix build on non-GCC compilers.Kenneth Graunke2010-09-071-3/+4
|
* glsl: Define GL_ES preprocessor macro if API is OpenGL ES 2.0.Kenneth Graunke2010-09-071-1/+8
| | | | Also define it if #version 100 is encountered.
* glsl: Include main/core.h.Chia-I Wu2010-08-241-1/+1
| | | | Make glsl include only main/core.h from core mesa.
* glcpp: Add support for "redefined macro" error.Carl Worth2010-08-171-2/+123
| | | | | | | | | Carefully avoiding printing any error when the new definition matches the existing definition. This fixes the recently-added 088-redefine-macro-legitimate.c and 089-redefine-macro-error.c tests as well as glsparsertest/preprocess1 in piglit.
* glcpp: Remove spurious newline generated by #version handling.Kenneth Graunke2010-08-161-1/+1
| | | | | | This was causing line numbering to be off by one. The newline comes from the NEWLINE token at the end of the line; there's no need to insert one.
* Revert "glsl2: Use stdint.h instead of inttypes.h"José Fonseca2010-08-141-1/+1
| | | | This reverts commit a77a6bc008b3146c56431fa520a00e1f8dfa3938.
* Fix an MSVC build error (bugzilla 29570).Vinson Lee2010-08-131-1/+1
|
* glsl2: Use stdint.h instead of inttypes.hIan Romanick2010-08-131-1/+1
|
* glsl2: Commit generated file changed by previous commitIan Romanick2010-08-121-0/+1
|
* glcpp: Fix "unterminated if" diagnostic.Carl Worth2010-08-111-2/+0
| | | | | | | | | | | This was previously being appended to the output string *after* a copy of the supposedly final string was made and handed to the caller. So the diagnostic was never actually visible to the user. We fix this by moving the check for an unterminated #if from glcpp_parser_destroy to the calling function, preprocess. This fixes the test case 083-unterminated-if.c.
* glcpp: Add an explicit diagnostic for #if with no expression.Carl Worth2010-08-111-0/+10
| | | | | | | 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.
* glcpp: Reword diagnostic for #elif with no expressionCarl Worth2010-08-111-1/+1
| | | | | | 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.
* glcpp: Additional fixes for not evaluating skipped #if/#elif expressions.Carl Worth2010-08-111-19/+41
| | | | | | 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).
* glcpp: Initialize location structure at beginning of parse.Carl Worth2010-08-101-0/+8
| | | | | | | | | | 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.
* glcpp: Ignore #if and #elif expressions when skipping.Kenneth Graunke2010-08-041-2/+16
| | | | | Fixes glcpp test cases 073 and 074, as well as piglit test xonotic-vs-generic-diffuse.vert.
* glcpp: Refactor HASH_IF and HASH_ELIF expansion to reuse code.Kenneth Graunke2010-08-041-20/+19
|
* glcpp: Remove xtalloc wrappers in favor of plain talloc.Kenneth Graunke2010-08-041-19/+19
| | | | | | 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.
* glsl2: Actually fix glsl-version-define.Eric Anholt2010-07-281-3/+0
|
* glcpp: Add __VERSION__ define to the current language version.Eric Anholt2010-07-281-26/+47
| | | | | | | Fixes: glsl-version-define glsl-version-define-110 glsl-version-define-120
* glcpp: Print integer tokens as decimal, not hex.Eric Anholt2010-07-281-1/+1
|
* glsl2: Add the define for ARB_fragment_coord_conventions when present.Eric Anholt2010-07-281-0/+8
| | | | | Fixes: glsl-arb-fragment-coord-conventions-define
* glcpp: Explicitly expect 0 shift/reduce conflicts.Carl Worth2010-07-281-0/+1
| | | | | | 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").
* glcpp: Remove 2 shift/reduce conflicts from the grammar.Carl Worth2010-07-281-1/+0
| | | | | | | 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.
* glcpp: Fix function-like macros with an argument used multiple times.Carl Worth2010-07-221-3/+7
| | | | | | | | | | | 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)
* glcpp: Avoid accidental token pasting in preprocessed result.Carl Worth2010-07-201-3/+18
| | | | | | | | | | | | | | | | | | | | | 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.
* glcpp: Add static keyword to several functions in the parser.Carl Worth2010-07-201-3/+3
| | | | This quiets warnings about missing declarations otherwise.
* glcpp: Fix use-after-free error from #undef directive.Carl Worth2010-07-201-4/+1
| | | | | | By taking advantage of the recently-added hash_table_remove function. With this change, all existing tests are now valgrind-clean.
* glsl2: Conditionally define preprocessor tokens for optional extensionsIan Romanick2010-07-011-1/+9
| | | | | The only optional extension currently supported by the compiler is GL_EXT_texture_array.
* glsl2: Define preprocessor tokens for extensionsIan Romanick2010-07-011-1/+17
| | | | | | 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.
* glsl2: Move the compiler to the subdirectory it will live in in Mesa.Eric Anholt2010-06-241-0/+1611