diff options
author | Ingo Kresse <ingo.kresse@kuka.com> | 2021-07-26 21:11:55 +0300 |
---|---|---|
committer | Petteri Aimonen <jpa@git.mail.kapsi.fi> | 2021-07-27 08:34:34 +0300 |
commit | 863b7390b774313e4e7ab6a42c31bf0bfe846023 (patch) | |
tree | 15c482977b0e39fdb8b5d8e2d99ee8b127ea8490 /tests | |
parent | 9d11e05c79c6b89d96c550f4a2876d2e260e331c (diff) |
Emit size_union only once, with guards (#692)
Previously there could be double definition errors at compile time.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/regression/issue_692/SConscript | 9 | ||||
-rw-r--r-- | tests/regression/issue_692/oneof.proto | 19 | ||||
-rw-r--r-- | tests/regression/issue_692/other.proto | 9 | ||||
-rw-r--r-- | tests/regression/issue_692/test.c | 7 |
4 files changed, 44 insertions, 0 deletions
diff --git a/tests/regression/issue_692/SConscript b/tests/regression/issue_692/SConscript new file mode 100644 index 0000000..11f07ca --- /dev/null +++ b/tests/regression/issue_692/SConscript @@ -0,0 +1,9 @@ +# Regression test for #693: +# Duplicate declarations of size_unions with repeated fields inside a oneof + +Import("env") + +env.NanopbProto("other.proto") +env.NanopbProto(["oneof.proto", "other.proto"]) +env.Object("oneof.pb.c") +env.Object("test.c") diff --git a/tests/regression/issue_692/oneof.proto b/tests/regression/issue_692/oneof.proto new file mode 100644 index 0000000..7f7baaf --- /dev/null +++ b/tests/regression/issue_692/oneof.proto @@ -0,0 +1,19 @@ +syntax = "proto3"; + +import "other.proto"; + +message FirstOneof {} + +message Bar { + oneof content { + FirstOneof first = 1; + SecondOneof second = 2; // unknown size if no options are considered + } +} + +message Foo { + AnotherList foo = 1; // again, unknown size + Bar bar = 2; // no duplicate size_union shall be generated anymore +} + + diff --git a/tests/regression/issue_692/other.proto b/tests/regression/issue_692/other.proto new file mode 100644 index 0000000..733103c --- /dev/null +++ b/tests/regression/issue_692/other.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +message SecondOneof { + repeated int32 foo = 1; +} + +message AnotherList { + repeated int32 bar = 1; +}
\ No newline at end of file diff --git a/tests/regression/issue_692/test.c b/tests/regression/issue_692/test.c new file mode 100644 index 0000000..95281b7 --- /dev/null +++ b/tests/regression/issue_692/test.c @@ -0,0 +1,7 @@ +/* This fakes the situation where other.proto was not found at generation time, + so size_union declarations are generated. */ + +#define SecondOneof_size 88 +#define AnotherList_size 88 + +#include "oneof.pb.h" |