[Mesa-dev] [PATCH 3/5] glcpp: Allow arithmetic integer expressions in #line

Carl Worth cworth at cworth.org
Tue Jun 9 10:40:45 PDT 2015


On Tue, Jun 09 2015, Ian Romanick wrote:
>> From section 3.4 ("Preprocessor") of the GLSL ES 3.00 specification:
>> "#line must have, after macro substitution, one of the following forms:
>>    	#line line
>>    	#line line source-string-number
>> where line and source-string-number are constant integral
>> expressions."
...
>> From section 4.3.3 ("Constant Expressions") of the same specification:
>> "A constant integral expression is a constant expression that evaluates
>> to a scalar signed or unsigned integer."

Yes. That's an extremely unfortunate piece of the specification.

This, together with unary operators introduces inherent ambiguity into
the grammar. Just think about things like:

#line 2-1+5
#line 2 -1+5
#line 2-1 +5

#line 2-1+5 3
#line 2 -1+5 3
#line 2-1 +5 3

That's off the top of my head. I'll dig through some old branches to see
if I have some other gems for testing this stuff.

> FFS.  I can't believe they have a test for this.  For what it's worth,
> this makes the grammar non-LALR.  Not too long ago it came up for a vote
> to remove this since it does not work on *ANY* desktop OpenGL
> implementation.  While there was a majority vote to remove it, it was
> not a large enough majority (by a single vote).  It is also a deviation
> from C / C++ preprocessors.
>
> Carl spent some time on this, and he couldn't find a way to make it work
> without adding significant bison warnings or have it fail for some
> cases.

I would definitely push back against anyone enforcing this piece of the
specification in a test suite. It's language that really doesn't belong
in the specification.

But I'll also take a look at this patch. Thanks for bringing it to my
attention, Ian.

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150609/6b61c80a/attachment.sig>


More information about the mesa-dev mailing list