rejects circular references
Circular references can't be resolved.
For example,
enum E { A = B, B }
parcelable P { const int A = A + 1; }
Bug: 174926968
Bug: 174903521
Test: aidl_unittests
Change-Id: Ief63b3ec2db749d477ad07594cb2797a885ba145
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index 3f62b15..0c69d39 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -4150,5 +4150,27 @@
"std::vector<::aidl::p::Bar> bars = {::aidl::p::Bar::FOO, ::aidl::p::Bar::FOO};"));
}
+TEST_F(AidlTest, RejectsCircularReferencingEnumerators) {
+ io_delegate_.SetFileContents("a/p/Foo.aidl", "package p; enum Foo { A = B, B }");
+ CaptureStderr();
+ auto options = Options::From("aidl -I a --lang ndk -o out -h out a/p/Foo.aidl");
+ EXPECT_EQ(1, aidl::compile_aidl(options, io_delegate_));
+ auto err = GetCapturedStderr();
+ EXPECT_EQ("ERROR: a/p/Foo.aidl:1.26-28: Failed to parse expression as integer: B\n", err);
+}
+
+TEST_F(AidlTest, RejectsCircularReferencingConsts) {
+ io_delegate_.SetFileContents("a/p/Foo.aidl",
+ "package p; parcelable Foo { const int A = A + 1; }");
+ CaptureStderr();
+ auto options = Options::From("aidl -I a --lang ndk -o out -h out a/p/Foo.aidl");
+ EXPECT_EQ(1, aidl::compile_aidl(options, io_delegate_));
+ auto err = GetCapturedStderr();
+ EXPECT_EQ(
+ "ERROR: a/p/Foo.aidl:1.42-44: Can't evaluate the circular reference (A)\n"
+ "ERROR: a/p/Foo.aidl:1.42-44: Invalid left operand in binary expression: A+1\n",
+ err);
+}
+
} // namespace aidl
} // namespace android