glcpp: error on multiple #else/#elif directives
authorErik Faye-Lund <kusmabite@gmail.com>
Tue, 17 Dec 2013 15:37:33 +0000 (16:37 +0100)
committerCarl Worth <cworth@cworth.org>
Thu, 2 Jan 2014 22:22:58 +0000 (14:22 -0800)
commiteb212c5a302f0122a13b36dfdf07e91f951ae2e7
tree82582edde6697d40e7496d1e994fea21cfdf6027
parent6005e9cb283214cd57038c7c5e7758ba72ec6ac2
glcpp: error on multiple #else/#elif directives

The preprocessor currently accepts multiple else/elif-groups
per if-section. The GLSL-preprocessor is defined by the C++
specification, which defines the following parse-rule:

if-section:
if-group elif-groups(opt) else-group(opt) endif-line

This clearly only allows a single else-group, that has to come
after any elif-groups.

So let's modify the code to follow the specification. Add test
to prevent regressions.

Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Carl Worth <cworth@cworth.org>
Cc: 10.0 <mesa-stable@lists.freedesktop.org>
src/glsl/glcpp/glcpp-parse.y
src/glsl/glcpp/glcpp.h
src/glsl/glcpp/tests/118-multiple-else.c [new file with mode: 0644]
src/glsl/glcpp/tests/118-multiple-else.c.expected [new file with mode: 0644]
src/glsl/glcpp/tests/119-elif-after-else.c [new file with mode: 0644]
src/glsl/glcpp/tests/119-elif-after-else.c.expected [new file with mode: 0644]