added constant folding & branch elimination to skslc
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2489673002
Committed: https://skia.googlesource.com/skia/+/6136310ee8f43247548bcefcaeca6d43023c10aa
Review-Url: https://codereview.chromium.org/2489673002
diff --git a/tests/SkSLErrorTest.cpp b/tests/SkSLErrorTest.cpp
index 9e89b71..fc20fa2 100644
--- a/tests/SkSLErrorTest.cpp
+++ b/tests/SkSLErrorTest.cpp
@@ -352,3 +352,19 @@
"void foo() { for(;;); continue; }",
"error: 1: continue statement must be inside a loop\n1 error\n");
}
+
+DEF_TEST(SkSLStaticIfError, r) {
+ // ensure eliminated branch of static if / ternary is still checked for errors
+ test_failure(r,
+ "void foo() { if (true); else x = 5; }",
+ "error: 1: unknown identifier 'x'\n1 error\n");
+ test_failure(r,
+ "void foo() { if (false) x = 5; }",
+ "error: 1: unknown identifier 'x'\n1 error\n");
+ test_failure(r,
+ "void foo() { true ? 5 : x; }",
+ "error: 1: unknown identifier 'x'\n1 error\n");
+ test_failure(r,
+ "void foo() { false ? x : 5; }",
+ "error: 1: unknown identifier 'x'\n1 error\n");
+}