Skip to content

Commit

Permalink
[cleanup] Suppress MSVC Warning in Generated C++ Files (protocolbuffe…
Browse files Browse the repository at this point in the history
…rs#10353)

* Add static_cast so that generated files do not emit warning

* Address PR feedback

* Updates after running generate_descriptor_proto.sh

Co-authored-by: Tushar Bhatnagar <[email protected]>
Co-authored-by: Adam Cozzette <[email protected]>
  • Loading branch information
3 people authored Aug 12, 2022
1 parent 043cb56 commit caff3c2
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/google/protobuf/api.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/google/protobuf/compiler/cpp/parse_function_generator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1102,10 +1102,10 @@ void ParseFunctionGenerator::GenerateFieldBody(
format.Set("enum_type",
QualifiedClassName(field->enum_type(), options_));
format(
"$uint64$ val = ::$proto_ns$::internal::ReadVarint64(&ptr);\n"
"$uint32$ val = ::$proto_ns$::internal::ReadVarint32(&ptr);\n"
"CHK_(ptr);\n");
if (!internal::cpp::HasPreservingUnknownEnumSemantics(field)) {
format("if (PROTOBUF_PREDICT_TRUE($enum_type$_IsValid(val))) {\n");
format("if (PROTOBUF_PREDICT_TRUE($enum_type$_IsValid(static_cast<int>(val)))) {\n");
format.Indent();
}
format("$msg$_internal_$put_field$(static_cast<$enum_type$>(val));\n");
Expand Down
28 changes: 14 additions & 14 deletions src/google/protobuf/descriptor.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/google/protobuf/struct.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/google/protobuf/type.pb.cc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit caff3c2

Please sign in to comment.