Generate an error for skipped root() params in HC.
BUG=5439760
Change-Id: Ie41ef5feac1637c8fe146f065416f3d33527b0bb
diff --git a/slang_rs_export_foreach.cpp b/slang_rs_export_foreach.cpp
index 7f03832..faa5f17 100644
--- a/slang_rs_export_foreach.cpp
+++ b/slang_rs_export_foreach.cpp
@@ -28,6 +28,7 @@
#include "slang_assert.h"
#include "slang_rs_context.h"
#include "slang_rs_export_type.h"
+#include "slang_version.h"
namespace slang {
@@ -180,6 +181,26 @@
mMetadataEncoding |= (mY ? 0x10 : 0);
}
+ if (Context->getTargetAPI() < SLANG_ICS_TARGET_API) {
+ // APIs before ICS cannot skip between parameters. It is ok, however, for
+ // them to omit further parameters (i.e. skipping X is ok if you skip Y).
+ if (mMetadataEncoding != 0x1f && // In, Out, UsrData, X, Y
+ mMetadataEncoding != 0x0f && // In, Out, UsrData, X
+ mMetadataEncoding != 0x07 && // In, Out, UsrData
+ mMetadataEncoding != 0x03 && // In, Out
+ mMetadataEncoding != 0x01) { // In
+ Diags->Report(
+ clang::FullSourceLoc(FD->getLocation(),
+ Diags->getSourceManager()),
+ Diags->getCustomDiagID(clang::Diagnostic::Error,
+ "Compute root() targeting SDK levels %0-%1 "
+ "may not skip parameters"))
+ << SLANG_MINIMUM_TARGET_API << (SLANG_ICS_TARGET_API-1);
+ valid = false;
+ }
+ }
+
+
return valid;
}
diff --git a/tests/F_root_11_ox/root_11_ox.rs b/tests/F_root_11_ox/root_11_ox.rs
new file mode 100644
index 0000000..00278d2
--- /dev/null
+++ b/tests/F_root_11_ox/root_11_ox.rs
@@ -0,0 +1,6 @@
+// -target-api 11
+#pragma version(1)
+#pragma rs java_package_name(foo)
+
+void root(int *out, uint32_t x) {
+}
diff --git a/tests/F_root_11_ox/stderr.txt.expect b/tests/F_root_11_ox/stderr.txt.expect
new file mode 100644
index 0000000..2e5e9de
--- /dev/null
+++ b/tests/F_root_11_ox/stderr.txt.expect
@@ -0,0 +1 @@
+root_11_ox.rs:5:6: error: Compute root() targeting SDK levels 11-13 may not skip parameters
diff --git a/tests/F_root_11_ox/stdout.txt.expect b/tests/F_root_11_ox/stdout.txt.expect
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/F_root_11_ox/stdout.txt.expect
diff --git a/tests/P_root_11_i/root_11_i.rs b/tests/P_root_11_i/root_11_i.rs
new file mode 100644
index 0000000..105569f
--- /dev/null
+++ b/tests/P_root_11_i/root_11_i.rs
@@ -0,0 +1,6 @@
+// -target-api 11
+#pragma version(1)
+#pragma rs java_package_name(foo)
+
+void root(const int *in) {
+}
diff --git a/tests/P_root_11_i/stderr.txt.expect b/tests/P_root_11_i/stderr.txt.expect
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/P_root_11_i/stderr.txt.expect
diff --git a/tests/P_root_11_i/stdout.txt.expect b/tests/P_root_11_i/stdout.txt.expect
new file mode 100644
index 0000000..d1bca5e
--- /dev/null
+++ b/tests/P_root_11_i/stdout.txt.expect
@@ -0,0 +1 @@
+Generating ScriptC_root_11_i.java ...
diff --git a/tests/P_root_11_iouxy/root_11_iouxy.rs b/tests/P_root_11_iouxy/root_11_iouxy.rs
new file mode 100644
index 0000000..2cd0667
--- /dev/null
+++ b/tests/P_root_11_iouxy/root_11_iouxy.rs
@@ -0,0 +1,6 @@
+// -target-api 11
+#pragma version(1)
+#pragma rs java_package_name(foo)
+
+void root(const int *in, int *out, const int *usrData, uint32_t x, uint32_t y) {
+}
diff --git a/tests/P_root_11_iouxy/stderr.txt.expect b/tests/P_root_11_iouxy/stderr.txt.expect
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/P_root_11_iouxy/stderr.txt.expect
diff --git a/tests/P_root_11_iouxy/stdout.txt.expect b/tests/P_root_11_iouxy/stdout.txt.expect
new file mode 100644
index 0000000..32fc9ba
--- /dev/null
+++ b/tests/P_root_11_iouxy/stdout.txt.expect
@@ -0,0 +1 @@
+Generating ScriptC_root_11_iouxy.java ...