diff options
Diffstat (limited to 'src/google')
-rw-r--r-- | src/google/protobuf/compiler/csharp/csharp_enum.cc | 17 | ||||
-rw-r--r-- | src/google/protobuf/message.cc | 12 | ||||
-rw-r--r-- | src/google/protobuf/unittest_proto3.proto | 3 |
3 files changed, 22 insertions, 10 deletions
diff --git a/src/google/protobuf/compiler/csharp/csharp_enum.cc b/src/google/protobuf/compiler/csharp/csharp_enum.cc index 9e4da1ed..9759e3ef 100644 --- a/src/google/protobuf/compiler/csharp/csharp_enum.cc +++ b/src/google/protobuf/compiler/csharp/csharp_enum.cc @@ -65,6 +65,7 @@ void EnumGenerator::Generate(io::Printer* printer) { "name", descriptor_->name()); printer->Indent(); std::set<string> used_names; + std::set<int> used_number; for (int i = 0; i < descriptor_->value_count(); i++) { WriteEnumValueDocComment(printer, descriptor_->value(i)); string original_name = descriptor_->value(i)->name(); @@ -76,10 +77,18 @@ void EnumGenerator::Generate(io::Printer* printer) { << ") in " << descriptor_->name() << "; adding underscore to distinguish"; name += "_"; } - printer->Print("[pbr::OriginalName(\"$original_name$\")] $name$ = $number$,\n", - "original_name", original_name, - "name", name, - "number", SimpleItoa(descriptor_->value(i)->number())); + int number = descriptor_->value(i)->number(); + if (!used_number.insert(number).second) { + printer->Print("[pbr::OriginalName(\"$original_name$\", PreferredAlias = false)] $name$ = $number$,\n", + "original_name", original_name, + "name", name, + "number", SimpleItoa(number)); + } else { + printer->Print("[pbr::OriginalName(\"$original_name$\")] $name$ = $number$,\n", + "original_name", original_name, + "name", name, + "number", SimpleItoa(number)); + } } printer->Outdent(); printer->Print("}\n"); diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc index b799dead..6800e4cd 100644 --- a/src/google/protobuf/message.cc +++ b/src/google/protobuf/message.cc @@ -451,8 +451,8 @@ struct ShutdownRepeatedFieldRegister { namespace internal { template<> -#if defined(_MSC_VER) && (_MSC_VER >= 1900) -// Note: force noinline to workaround MSVC 2015 compiler bug, issue #240 +#if defined(_MSC_VER) && (_MSC_VER >= 1800) +// Note: force noinline to workaround MSVC compiler bug with /Zc:inline, issue #240 GOOGLE_ATTRIBUTE_NOINLINE #endif Message* GenericTypeHandler<Message>::NewFromPrototype( @@ -460,8 +460,8 @@ Message* GenericTypeHandler<Message>::NewFromPrototype( return prototype->New(arena); } template<> -#if defined(_MSC_VER) && (_MSC_VER >= 1900) -// Note: force noinline to workaround MSVC 2015 compiler bug, issue #240 +#if defined(_MSC_VER) && (_MSC_VER >= 1800) +// Note: force noinline to workaround MSVC compiler bug with /Zc:inline, issue #240 GOOGLE_ATTRIBUTE_NOINLINE #endif google::protobuf::Arena* GenericTypeHandler<Message>::GetArena( @@ -469,8 +469,8 @@ google::protobuf::Arena* GenericTypeHandler<Message>::GetArena( return value->GetArena(); } template<> -#if defined(_MSC_VER) && (_MSC_VER >= 1900) -// Note: force noinline to workaround MSVC 2015 compiler bug, issue #240 +#if defined(_MSC_VER) && (_MSC_VER >= 1800) +// Note: force noinline to workaround MSVC compiler bug with /Zc:inline, issue #240 GOOGLE_ATTRIBUTE_NOINLINE #endif void* GenericTypeHandler<Message>::GetMaybeArenaPointer( diff --git a/src/google/protobuf/unittest_proto3.proto b/src/google/protobuf/unittest_proto3.proto index f59d2178..a27b1b26 100644 --- a/src/google/protobuf/unittest_proto3.proto +++ b/src/google/protobuf/unittest_proto3.proto @@ -200,6 +200,9 @@ message TestMutualRecursionB { int32 optional_int32 = 2; } +message TestEnumAllowAlias { + TestEnumWithDupValue value = 1; +} // Test an enum that has multiple values with the same number. enum TestEnumWithDupValue { |