[WHLSL] Variables shouldn't be able to have void type
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Aug 2019 03:36:22 +0000 (03:36 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Aug 2019 03:36:22 +0000 (03:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200751

Reviewed by Robin Morisset.

Source/WebCore:

Trivial fix. Found by https://github.com/gpuweb/WHLSL/issues/320.

Test: webgpu/whlsl/void-variable-parameter.html

* Modules/webgpu/WHLSL/WHLSLChecker.cpp:
(WebCore::WHLSL::Checker::visit):

LayoutTests:

* webgpu/whlsl/void-variable-parameter-expected.txt: Added.
* webgpu/whlsl/void-variable-parameter.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248706 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/webgpu/whlsl/void-variable-parameter-expected.txt [new file with mode: 0644]
LayoutTests/webgpu/whlsl/void-variable-parameter.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp

index b99dcdd..6a6dc19 100644 (file)
@@ -1,3 +1,13 @@
+2019-08-14  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [WHLSL] Variables shouldn't be able to have void type
+        https://bugs.webkit.org/show_bug.cgi?id=200751
+
+        Reviewed by Robin Morisset.
+
+        * webgpu/whlsl/void-variable-parameter-expected.txt: Added.
+        * webgpu/whlsl/void-variable-parameter.html: Added.
+
 2019-08-14  Zalan Bujtas  <zalan@apple.com>
 
         [ContentChangeObserver] Any previously destroyed renderer should not be considered a candidate for content observation.
diff --git a/LayoutTests/webgpu/whlsl/void-variable-parameter-expected.txt b/LayoutTests/webgpu/whlsl/void-variable-parameter-expected.txt
new file mode 100644 (file)
index 0000000..bac636c
--- /dev/null
@@ -0,0 +1,4 @@
+
+PASS voidVariable 
+PASS voidParameter 
+
diff --git a/LayoutTests/webgpu/whlsl/void-variable-parameter.html b/LayoutTests/webgpu/whlsl/void-variable-parameter.html
new file mode 100644 (file)
index 0000000..baf6195
--- /dev/null
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<meta charset=utf-8>
+<meta name="timeout" content="long">
+<title>Test structs.</title>
+<script src="js/test-harness.js"></script>
+<script src="../js/webgpu-functions.js"></script>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script>
+const whlslTests = {};
+
+whlslTests.voidVariable = async () =>
+{
+    await checkFail(
+        `
+            void foo() {
+                void x;
+            }
+        `);
+}
+
+whlslTests.voidParameter = async () =>
+{
+    await checkFail(
+        `
+            void foo(void x) {
+            }
+        `);
+}
+
+runTests(whlslTests);
+</script>
+</html>
+
index 055eb3a..f5bc8f0 100644 (file)
@@ -1,3 +1,17 @@
+2019-08-14  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        [WHLSL] Variables shouldn't be able to have void type
+        https://bugs.webkit.org/show_bug.cgi?id=200751
+
+        Reviewed by Robin Morisset.
+
+        Trivial fix. Found by https://github.com/gpuweb/WHLSL/issues/320.
+
+        Test: webgpu/whlsl/void-variable-parameter.html
+
+        * Modules/webgpu/WHLSL/WHLSLChecker.cpp:
+        (WebCore::WHLSL::Checker::visit):
+
 2019-08-14  Justin Fan  <justin_fan@apple.com>
 
         [WebGPU] Use of WebGPU should not force discrete GPU
index 77da48e..901c610 100644 (file)
@@ -952,6 +952,10 @@ void Checker::visit(AST::VariableDeclaration& variableDeclaration)
     // ReadModifyWriteExpressions are the only place where anonymous variables exist,
     // and that doesn't recurse on the anonymous variables, so we can assume the variable has a type.
     checkErrorAndVisit(*variableDeclaration.type());
+    if (matches(*variableDeclaration.type(), m_intrinsics.voidType())) {
+        setError(Error("Variables can't have void type.", variableDeclaration.codeLocation()));
+        return;
+    }
     if (variableDeclaration.initializer()) {
         auto& lhsType = *variableDeclaration.type();
         auto initializerInfo = recurseAndGetInfo(*variableDeclaration.initializer());