aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYi Kong <yikong@google.com>2022-02-28 15:56:28 +0800
committerYi Kong <yikong@google.com>2022-02-28 16:01:25 +0800
commitd5f12084981794159a927fe38362d165cfc77c1a (patch)
tree9b0a5ae6c2854f420650d70c9bd0d87e9eec9907
parent76b848a41f0b2a67c20bd0464ce52a6f7f257cbb (diff)
downloadhidl-d5f12084981794159a927fe38362d165cfc77c1a.tar.gz
Suppress int-in-bool-context warning
The compiler doesn't know T is at least KIND_INT32, and will instaniate bool version of the function, and will warn about converting the result of '<<' to a boolean. Test: presubmit Bug: 148287349 Change-Id: Iba73d80a1e1439ba18eb933d2f0e7614409fa7af
-rw-r--r--ConstantExpression.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/ConstantExpression.cpp b/ConstantExpression.cpp
index 02fbf760..6930c0f4 100644
--- a/ConstantExpression.cpp
+++ b/ConstantExpression.cpp
@@ -137,6 +137,11 @@ T handleBinaryCommon(T lval, const std::string& op, T rval) {
return static_cast<T>(0xdeadbeef);
}
+// The compiler doesn't know T is at least KIND_INT32, and will instantiate bool
+// version of this function, and will warn about converting the result of '<<'
+// to a boolean.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wint-in-bool-context"
template <class T>
T handleShift(T lval, const std::string& op, int64_t rval) {
// just cast rval to int64_t and it should fit.
@@ -147,6 +152,7 @@ T handleShift(T lval, const std::string& op, int64_t rval) {
<< lval << " " << op << " " << rval;
return static_cast<T>(0xdeadbeef);
}
+#pragma GCC diagnostic pop
bool handleLogical(bool lval, const std::string& op, bool rval) {
COMPUTE_BINARY(||);