[Mesa-dev] A few fixes for the preprocessor for GLSL 1.30

Carl Worth cworth at cworth.org
Fri Sep 30 14:49:25 PDT 2011


On Fri, 30 Sep 2011 12:32:13 -0700, Ian Romanick <idr at freedesktop.org> wrote:
> > In any case, the test quotes specific language from the GLSL spec that
> > explicitly forbids this behavior, so I'm somewhat reluctant to deviate
> > from the spec'ed behavior.

We're not deviating from what is specified.

We do raise an error when an undefined macro is used within an #if or
#elif (other than as an argument to "defined").

The only difference between our implementation and the original test is
that is that the test expected us to flag this error when the condition
was irrelevant, such as this:

#if 0
...
#elif UNDEFINED_MACRO
...
#endif

And that is not actually explicitly called out by the spec.

> Though, it turns out that this deviates from what C99 specifies. 
> Specifically, the ISO/IEC 9899:TC2 Committee Draft dated May 6, 2005 says:
> 
>      "After all replacements due to macro expansion and the defined unary
>      operator have been performed, all remaining identifiers are replaced
>      with the pp-number 0..."

Yes, I noticed this was different when I did the original
implementation. It wasn't hard to do what the GLSL specification says.

> I've submitted a GLSL spec bug.

OK. If GLSL should align better with C99 then that's a good plan.

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20110930/7c5eebc8/attachment.pgp>


More information about the mesa-dev mailing list