resolved conflicts for merge of f736d5a1 to ics-mr1
Change-Id: If31e6d49af2571458500f42f8cc2310758dfaa26
diff --git a/slang_rs_context.cpp b/slang_rs_context.cpp
index e1a2857..980038c 100644
--- a/slang_rs_context.cpp
+++ b/slang_rs_context.cpp
@@ -116,7 +116,7 @@
return false;
}
- if (RSExportForEach::isRSForEachFunc(FD)) {
+ if (RSExportForEach::isRSForEachFunc(mTargetAPI, FD)) {
RSExportForEach *EFE = RSExportForEach::Create(this, FD);
if (EFE == NULL)
return false;
@@ -125,7 +125,8 @@
return true;
} else if (RSExportForEach::isSpecialRSFunc(FD)) {
// Do not reflect specialized RS functions like init or graphics root.
- if (!RSExportForEach::validateSpecialFuncDecl(getDiagnostics(), FD)) {
+ if (!RSExportForEach::validateSpecialFuncDecl(mTargetAPI,
+ getDiagnostics(), FD)) {
return false;
}
return true;
diff --git a/slang_rs_export_foreach.cpp b/slang_rs_export_foreach.cpp
index e5d0176..a4025ca 100644
--- a/slang_rs_export_foreach.cpp
+++ b/slang_rs_export_foreach.cpp
@@ -294,7 +294,8 @@
return FE;
}
-bool RSExportForEach::isRSForEachFunc(const clang::FunctionDecl *FD) {
+bool RSExportForEach::isRSForEachFunc(int targetAPI,
+ const clang::FunctionDecl *FD) {
// We currently support only compute root() being exported via forEach
if (!isRootRSFunc(FD)) {
return false;
@@ -304,11 +305,24 @@
// Graphics compute function
return false;
}
+
+ // Handle legacy graphics root functions.
+ if ((targetAPI < SLANG_ICS_TARGET_API) && (FD->getNumParams() == 1)) {
+ const clang::ParmVarDecl *PVD = FD->getParamDecl(0);
+ clang::QualType QT = PVD->getType().getCanonicalType();
+ const clang::QualType &IntType = FD->getASTContext().IntTy;
+ if ((FD->getResultType().getCanonicalType() == IntType) &&
+ (QT == IntType)) {
+ return false;
+ }
+ }
+
return true;
}
bool
-RSExportForEach::validateSpecialFuncDecl(clang::DiagnosticsEngine *DiagEngine,
+RSExportForEach::validateSpecialFuncDecl(int targetAPI,
+ clang::DiagnosticsEngine *DiagEngine,
clang::FunctionDecl const *FD) {
slangAssert(DiagEngine && FD);
bool valid = true;
@@ -327,6 +341,9 @@
"an int for graphics usage"));
valid = false;
}
+ } else if ((targetAPI < SLANG_ICS_TARGET_API) && (numParams == 1)) {
+ // Legacy graphics root function
+ // This has already been validated in isRSForEachFunc().
} else {
slangAssert(false &&
"Should not call validateSpecialFuncDecl() on compute root()");
diff --git a/slang_rs_export_foreach.h b/slang_rs_export_foreach.h
index 0143110..bb9c1a0 100644
--- a/slang_rs_export_foreach.h
+++ b/slang_rs_export_foreach.h
@@ -148,13 +148,14 @@
return Name.equals(FuncDtor);
}
- static bool isRSForEachFunc(const clang::FunctionDecl *FD);
+ static bool isRSForEachFunc(int targetAPI, const clang::FunctionDecl *FD);
inline static bool isSpecialRSFunc(const clang::FunctionDecl *FD) {
return isRootRSFunc(FD) || isInitRSFunc(FD) || isDtorRSFunc(FD);
}
- static bool validateSpecialFuncDecl(clang::DiagnosticsEngine *DiagEngine,
+ static bool validateSpecialFuncDecl(int targetAPI,
+ clang::DiagnosticsEngine *DiagEngine,
const clang::FunctionDecl *FD);
}; // RSExportForEach
diff --git a/tests/F_root_graphics_13/root_graphics_13.rs b/tests/F_root_graphics_13/root_graphics_13.rs
new file mode 100644
index 0000000..c6c1fbd
--- /dev/null
+++ b/tests/F_root_graphics_13/root_graphics_13.rs
@@ -0,0 +1,7 @@
+// -target-api 13
+#pragma version(1)
+#pragma rs java_package_name(foo)
+
+int root(unsigned int launchID) {
+ return 10;
+}
diff --git a/tests/F_root_graphics_13/stderr.txt.expect b/tests/F_root_graphics_13/stderr.txt.expect
new file mode 100644
index 0000000..5670930
--- /dev/null
+++ b/tests/F_root_graphics_13/stderr.txt.expect
@@ -0,0 +1,3 @@
+root_graphics_13.rs:5:5: error: compute root() is required to return a void type
+root_graphics_13.rs:5:5: error: Compute root() must have at least one parameter for in or out
+root_graphics_13.rs:5:5: error: Compute root() targeting SDK levels 11-13 may not skip parameters
diff --git a/tests/F_root_graphics_13/stdout.txt.expect b/tests/F_root_graphics_13/stdout.txt.expect
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/F_root_graphics_13/stdout.txt.expect
diff --git a/tests/P_root_graphics_13/root_graphics_13.rs b/tests/P_root_graphics_13/root_graphics_13.rs
new file mode 100644
index 0000000..882bea1
--- /dev/null
+++ b/tests/P_root_graphics_13/root_graphics_13.rs
@@ -0,0 +1,9 @@
+// -target-api 13
+#pragma version(1)
+#pragma rs java_package_name(foo)
+
+typedef int myInt;
+
+myInt root(myInt launchID) {
+ return 10;
+}
diff --git a/tests/P_root_graphics_13/stderr.txt.expect b/tests/P_root_graphics_13/stderr.txt.expect
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/P_root_graphics_13/stderr.txt.expect
diff --git a/tests/P_root_graphics_13/stdout.txt.expect b/tests/P_root_graphics_13/stdout.txt.expect
new file mode 100644
index 0000000..f61211e
--- /dev/null
+++ b/tests/P_root_graphics_13/stdout.txt.expect
@@ -0,0 +1 @@
+Generating ScriptC_root_graphics_13.java ...