Fix LONG_COMMENT rule (lexer)
LONG_COMMENT is an exclusive start state. It should keep original state
and restore it.
Bug: 171770504
Test: aidl_unittests
Change-Id: Ic29f265ea7d89754d006102d5bc912a3c4058252
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index 3635ad2..e58c9ce 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -3511,6 +3511,15 @@
EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
+TEST_P(AidlTest, LongCommentWithinConstExpression) {
+ io_delegate_.SetFileContents("Foo.aidl", "enum Foo { FOO = (1 << 1) /* comment */ | 0x0 }");
+ Options options =
+ Options::From("aidl Foo.aidl --lang=" + Options::LanguageToString(GetLanguage()));
+ CaptureStderr();
+ EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_));
+ EXPECT_EQ("", GetCapturedStderr());
+}
+
constexpr char kDescriptContentsWithUntypedListMapInJava[] = R"(
@Override
public int describeContents() {