diff options
author | Carl Worth <cworth@cworth.org> | 2013-02-22 13:18:25 -0800 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2013-03-01 14:08:57 -0800 |
commit | b10c5f34a26d1e3b305de8e2d6a6e8e7bc4f4b1f (patch) | |
tree | 788eefa2bbdab242edadb35df2b489034b780773 | |
parent | 131b2132cc96b4a5bad8fa237a4a88b759b961e7 (diff) |
Change expected behavior for #if with undefined macros.
The GLSL 1.30 specification deviated from the standard behavior of C
preprocessors everywhere 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
Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
-rw-r--r-- | tests/spec/glsl-1.30/preprocessor/if/if-arg-must-be-defined-01.frag | 14 | ||||
-rw-r--r-- | tests/spec/glsl-1.30/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 019104df..4fd5d874 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 520344a0..0aef7de3 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; |