[Mesa-dev] [PATCH 3/5] glcpp: Allow arithmetic integer expressions in #line
Ian Romanick
idr at freedesktop.org
Tue Jun 9 10:59:53 PDT 2015
On 06/09/2015 10:40 AM, Carl Worth wrote:
> 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.
The spec was supposed to get updated to say that parsing is greedy, so
we at least know what those should do. I say "supposed to" instead of
"was" because I don't know for sure that it was updated.
>> 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: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20150609/c3129da9/attachment.sig>
More information about the mesa-dev
mailing list