Elevate bitwise bool negation error to clients.
This is a potentially useful error, since the behavior is confusing.
Bug: N/A
Test: TEST_MAPPING
Change-Id: I0f02ff98be0d344c5be8a0ba1200fb8ea93a54a0
diff --git a/aidl_const_expressions.cpp b/aidl_const_expressions.cpp
index f88ef94..214c759 100644
--- a/aidl_const_expressions.cpp
+++ b/aidl_const_expressions.cpp
@@ -74,13 +74,20 @@
COMPUTE_UNARY(+)
COMPUTE_UNARY(-)
COMPUTE_UNARY(!)
-
-// bitwise negation of a boolean expression always evaluates to 'true'
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wbool-operation"
COMPUTE_UNARY(~)
-#pragma clang diagnostic pop
+ AIDL_FATAL(context) << "Could not handleUnary for " << op << " " << val;
+ return false;
+}
+template <>
+bool handleUnary<bool>(const AidlConstantValue& context, const string& op, bool val, int64_t* out) {
+ COMPUTE_UNARY(+)
+ COMPUTE_UNARY(-)
+ COMPUTE_UNARY(!)
+ if (op == "~") {
+ AIDL_ERROR(context) << "Bitwise negation of a boolean expression is always true.";
+ return false;
+ }
AIDL_FATAL(context) << "Could not handleUnary for " << op << " " << val;
return false;
}