[Mesa-dev] [PATCH 5/6] glcpp: Raise error if defining any macro containing two consecutive underscores

Eric Anholt eric at anholt.net
Thu Sep 29 23:48:21 PDT 2011


On Thu, 29 Sep 2011 23:00:29 -0700, Carl Worth <cworth at cworth.org> wrote:
> The specification reserves any macro name containing two consecutive
> underscores, (anywhere within the name). Previously, we only raised
> this error for macro names that started with two underscores.
> 
> Fix the implementation to check for two underscores anywhere, and also
> update the corresponding 086-reserved-macro-names test.
> 
> This also fixes the following two piglit tests:
> 
> 	spec/glsl-1.30/preprocessor/reserved/double-underscore-02.frag
> 	spec/glsl-1.30/preprocessor/reserved/double-underscore-03.frag
> ---
>  src/glsl/glcpp/glcpp-parse.y                       |    4 ++--
>  src/glsl/glcpp/tests/086-reserved-macro-names.c    |    1 +
>  .../tests/086-reserved-macro-names.c.expected      |    5 ++++-
>  3 files changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
> index ff9fa7a..17941a9 100644
> --- a/src/glsl/glcpp/glcpp-parse.y
> +++ b/src/glsl/glcpp/glcpp-parse.y
> @@ -1663,8 +1663,8 @@ _check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc,
>  	/* According to the GLSL specification, macro names starting with "__"
>  	 * or "GL_" are reserved for future use.  So, don't allow them.
>  	 */
> -	if (strncmp(identifier, "__", 2) == 0) {
> -		glcpp_error (loc, parser, "Macro names starting with \"__\" are reserved.\n");
> +	if (strstr(identifier, "__")) {
> +		glcpp_error (loc, parser, "Macro names containing \"__\" are reserved.\n");
>  	}
>  	if (strncmp(identifier, "GL_", 3) == 0) {
>  		glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n");

Confirmed that this isn't new with 1.30 -- there's text for it back to
1.10 even.

Reviewed-by: Eric Anholt <eric at anholt.net>
-------------- 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/20110929/91b148d1/attachment.pgp>


More information about the mesa-dev mailing list