From aa09c782a8c1636c31b90bce1d498224b50b31ee Mon Sep 17 00:00:00 2001 From: John Stiles Date: Tue, 28 Dec 2021 14:58:36 -0500 Subject: [PATCH] Add test for structs/interface-blocks with invalid member names. Structs already handled this appropriately, but interface blocks did not guard against naming their member variables built-in type names like "float" or "bool". Change-Id: I12ec054b3f158b83e35031449cf2a088ff8d0dc2 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/489596 Auto-Submit: John Stiles Reviewed-by: Brian Osman --- gn/sksl_tests.gni | 2 ++ .../sksl/errors/InterfaceBlockMemberReservedName.sksl | 7 +++++++ resources/sksl/errors/StructMemberReservedName.sksl | 7 +++++++ tests/sksl/errors/InterfaceBlockMemberReservedName.glsl | 7 +++++++ tests/sksl/errors/StructMemberReservedName.glsl | 4 ++++ 5 files changed, 27 insertions(+) create mode 100644 resources/sksl/errors/InterfaceBlockMemberReservedName.sksl create mode 100644 resources/sksl/errors/StructMemberReservedName.sksl create mode 100644 tests/sksl/errors/InterfaceBlockMemberReservedName.glsl create mode 100644 tests/sksl/errors/StructMemberReservedName.glsl diff --git a/gn/sksl_tests.gni b/gn/sksl_tests.gni index cec34b292b..2cb56c7be0 100644 --- a/gn/sksl_tests.gni +++ b/gn/sksl_tests.gni @@ -66,6 +66,7 @@ sksl_error_tests = [ "/sksl/errors/InVarWithInitializerExpression.sksl", "/sksl/errors/IncompleteExpression.sksl", "/sksl/errors/IncompleteFunctionCall.sksl", + "/sksl/errors/InterfaceBlockMemberReservedName.sksl", "/sksl/errors/InterfaceBlockReservedName.sksl", "/sksl/errors/InterfaceBlockScope.sksl", "/sksl/errors/InterfaceBlockStorageModifiers.sksl", @@ -194,6 +195,7 @@ sksl_error_tests = [ "/sksl/errors/StaticSwitchWithConditionalBreak.sksl", "/sksl/errors/StaticSwitchWithConditionalContinue.sksl", "/sksl/errors/StaticSwitchWithConditionalReturn.sksl", + "/sksl/errors/StructMemberReservedName.sksl", "/sksl/errors/StructNameWithoutIdentifier.sksl", "/sksl/errors/StructTooDeeplyNested.sksl", "/sksl/errors/StructVariableReservedName.sksl", diff --git a/resources/sksl/errors/InterfaceBlockMemberReservedName.sksl b/resources/sksl/errors/InterfaceBlockMemberReservedName.sksl new file mode 100644 index 0000000000..93029fbe88 --- /dev/null +++ b/resources/sksl/errors/InterfaceBlockMemberReservedName.sksl @@ -0,0 +1,7 @@ +IB { + float float; +} ib; + +float4 main() { + return ib.float.xxxx; +} diff --git a/resources/sksl/errors/StructMemberReservedName.sksl b/resources/sksl/errors/StructMemberReservedName.sksl new file mode 100644 index 0000000000..f0a1788b9d --- /dev/null +++ b/resources/sksl/errors/StructMemberReservedName.sksl @@ -0,0 +1,7 @@ +struct S { + float float; +} s; + +float4 main() { + return s.float.xxxx; +} diff --git a/tests/sksl/errors/InterfaceBlockMemberReservedName.glsl b/tests/sksl/errors/InterfaceBlockMemberReservedName.glsl new file mode 100644 index 0000000000..d6b808f69a --- /dev/null +++ b/tests/sksl/errors/InterfaceBlockMemberReservedName.glsl @@ -0,0 +1,7 @@ + +IB { + float float; +} ib; +vec4 main() { + return vec4(ib.float); +} diff --git a/tests/sksl/errors/StructMemberReservedName.glsl b/tests/sksl/errors/StructMemberReservedName.glsl new file mode 100644 index 0000000000..1fe3b9b215 --- /dev/null +++ b/tests/sksl/errors/StructMemberReservedName.glsl @@ -0,0 +1,4 @@ +### Compilation failed: + +error: 2: expected an identifier, but found type 'float' +1 error