nested types: Reject unstructured parcelable
Having unstructured parcelables as nested types doesn't make sense
because they are defined somewhere else in native languages (e.g. C++,
Java...).
Bug: 182508839
Test: aidl_unittests
Change-Id: I4a6cd76ac58fc246db77c7e62d16403eabf90dda
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index c1a2137..e3a761b 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -1606,6 +1606,19 @@
EXPECT_THAT(GetCapturedStderr(), HasSubstr("Interfaces should be at the root scope"));
}
+TEST_F(AidlTest, RejectUnstructuredParcelableAsNestedTypes) {
+ const string input_path = "p/IFoo.aidl";
+ const string input =
+ "package p;\n"
+ "interface IFoo {\n"
+ " parcelable Bar cpp_header \"Bar.h\";\n"
+ "}";
+ CaptureStderr();
+ EXPECT_EQ(nullptr, Parse(input_path, input, typenames_, Options::Language::CPP));
+ EXPECT_THAT(GetCapturedStderr(),
+ HasSubstr("Unstructured parcelables should be at the root scope"));
+}
+
TEST_F(AidlTest, HandleSyntaxErrorsInNestedDecl) {
const string input_path = "p/IFoo.aidl";
const string input =