The GLSL 1.30 specification deviated from the standard behavior of C preprocessors everwhere by making an undefined macro an error rather than treating it as a value of 0. This was not actually useful, and this exception to the standard behavior is dropped in GLSL 4.30.
In the meantime, popular implementations have been ignoring the specified behavior and implementing the standard behavior anyway. So expect that. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=51631 --- .../preprocessor/if/if-arg-must-be-defined-01.frag | 14 +++++++++++--- .../preprocessor/if/if-arg-must-be-defined-02.frag | 18 +++++++++++++++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/tests/spec/glsl-1.30/preprocessor/if/if-arg-must-be-defined-01.frag b/tests/spec/glsl-1.30/preprocessor/if/if-arg-must-be-defined-01.frag index 019104d..4fd5d87 100644 --- a/tests/spec/glsl-1.30/preprocessor/if/if-arg-must-be-defined-01.frag +++ b/tests/spec/glsl-1.30/preprocessor/if/if-arg-must-be-defined-01.frag @@ -1,15 +1,23 @@ // [config] -// expect_result: fail +// expect_result:pass // glsl_version: 1.30 // [end config] // -// Check that the compiler raises an error when an undefined macro is used as +// Check that the compiler treats an undefined macro as 0 when used as // an argument to the #if directive. // -// From page 11 (17 of pdf) of the GLSL 1.30 spec: +// Older GLSL specifications (such as GLSL 1.30) had the following language: +// // "It is an error to use #if or #elif on expressions containing // undefined macro names, other than as arguments to the // defined operator." +// +// [Page 11 (17 of pdf) of the GLSL 1.30 spec] +// +// But GLSL 4.30 drops this, so that un undefined macro should be +// treated as 0 just as is standard for C preprocessors. Many +// implementations have been doing this already as it's what is +// standard for C preprocessors, so is expected by users. #version 130 diff --git a/tests/spec/glsl-1.30/preprocessor/if/if-arg-must-be-defined-02.frag b/tests/spec/glsl-1.30/preprocessor/if/if-arg-must-be-defined-02.frag index 520344a..0aef7de 100644 --- a/tests/spec/glsl-1.30/preprocessor/if/if-arg-must-be-defined-02.frag +++ b/tests/spec/glsl-1.30/preprocessor/if/if-arg-must-be-defined-02.frag @@ -1,15 +1,23 @@ // [config] -// expect_result: fail +// expect_result: pass // glsl_version: 1.30 // [end config] // -// Check that the compiler raises an error when an undefined macro is used as +// Check that the compiler treats an undefined macro as 0 when used as // an argument to the #elif directive. // -// From page 11 (17 of pdf) of the GLSL 1.30 spec: +// Older GLSL specifications (such as GLSL 1.30) had the following language: +// // "It is an error to use #if or #elif on expressions containing // undefined macro names, other than as arguments to the // defined operator." +// +// [Page 11 (17 of pdf) of the GLSL 1.30 spec] +// +// But GLSL 4.30 drops this, so that un undefined macro should be +// treated as 0 just as is standard for C preprocessors. Many +// implementations have been doing this already as it's what is +// standard for C preprocessors, so is expected by users. #version 130 @@ -19,6 +27,10 @@ # define JUNK 1 #endif +#if defined JUNK +#error Undefined macro should be treated as 0. +#endif + int f() { return 0; -- 1.7.10.4 _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
