aidl: support byte/long constants
before: 'const int foo = 3;'
now: 'const byte bar = 3;'
now: 'const long baz = 4;'
This is helpful to create constants which are a specific size, and it
opens up the ability to create larger constants.
Bug: 172246790
Test: atest aidl_unittests aidl_integration_test
Change-Id: I614658cd0a5e5eb6b0dea6d9212aa082cbb16317
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index 02cbf5f..9b899d1 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -958,6 +958,22 @@
EXPECT_EQ(AidlError::BAD_TYPE, error);
}
+TEST_P(AidlTest, FailOnTooBigConstant) {
+ AidlError error;
+ const string expected_stderr =
+ "ERROR: p/IFoo.aidl:3.48-52: Invalid type specifier for an int32 literal: byte\n";
+ CaptureStderr();
+ EXPECT_EQ(nullptr, Parse("p/IFoo.aidl",
+ R"(package p;
+ interface IFoo {
+ const byte type2small = 256;
+ }
+ )",
+ typenames_, GetLanguage(), &error));
+ EXPECT_EQ(expected_stderr, GetCapturedStderr());
+ EXPECT_EQ(AidlError::BAD_TYPE, error);
+}
+
TEST_P(AidlTest, FailOnManyDefinedTypes) {
AidlError error;
const string expected_stderr =