glcpp: Generate an error for division by zero
authorIan Romanick <ian.d.romanick@intel.com>
Mon, 10 Jan 2011 21:33:07 +0000 (13:33 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Tue, 11 Jan 2011 01:37:51 +0000 (17:37 -0800)
commit9ca5300b6e781150cec903c73cf5fd8e1deee2f1
tree5f699b0963d43d402a817efb5da322803f460cd1
parent4e09a786d20ee5a2793e29d1cf336ad5383da22b
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.
src/glsl/glcpp/glcpp-parse.y