aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/cpp
diff options
context:
space:
mode:
authorGravatar Adam Cozzette <acozzette@google.com>2016-11-22 15:44:54 -0800
committerGravatar Adam Cozzette <acozzette@google.com>2016-11-22 16:23:55 -0800
commitdb35fe735a6522089250a0a0804fb1fd18340666 (patch)
tree7b1532068eeadef058e1b5bf40056cbebfcee727 /src/google/protobuf/compiler/cpp
parenta7f300d6ffe2fbc6bdd10495efedbe6c86a29f49 (diff)
Add a "u" suffix to tag numbers in generated code
This seems to be necessary to prevent warnings in some compiler configurations, particularly for tag numbers that are too large to fit in a signed 32-bit int.
Diffstat (limited to 'src/google/protobuf/compiler/cpp')
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_enum_field.cc2
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_map_field.cc2
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message.cc8
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_primitive_field.cc2
4 files changed, 7 insertions, 7 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
index 093bf06c..b6658079 100644
--- a/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_enum_field.cc
@@ -147,7 +147,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
} else {
printer->Print(
"} else {\n"
- " unknown_fields_stream.WriteVarint32($tag$);\n"
+ " unknown_fields_stream.WriteVarint32($tag$u);\n"
" unknown_fields_stream.WriteVarint32(value);\n",
"tag", SimpleItoa(internal::WireFormat::MakeTag(descriptor_)));
}
diff --git a/src/google/protobuf/compiler/cpp/cpp_map_field.cc b/src/google/protobuf/compiler/cpp/cpp_map_field.cc
index c0e172b2..5c4b56f7 100644
--- a/src/google/protobuf/compiler/cpp/cpp_map_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_map_field.cc
@@ -230,7 +230,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
"->AddLengthDelimited($number$, data);\n");
} else {
printer->Print(variables_,
- " unknown_fields_stream.WriteVarint32($tag$);\n"
+ " unknown_fields_stream.WriteVarint32($tag$u);\n"
" unknown_fields_stream.WriteVarint32(data.size());\n"
" unknown_fields_stream.WriteString(data);\n");
}
diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc
index d878c4de..2b71acb5 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_message.cc
@@ -2984,7 +2984,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
}
printer->Print("::std::pair< ::google::protobuf::uint32, bool> p = "
- "input->ReadTagWithCutoff$lasttag$($max$);\n"
+ "input->ReadTagWithCutoff$lasttag$($max$u);\n"
"tag = p.first;\n"
"if (!p.second) goto handle_unusual;\n",
"max", SimpleItoa(maxtag <= kCutoff0 ? kCutoff0 :
@@ -3037,7 +3037,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
const FieldGenerator& field_generator = field_generators_.get(field);
// Emit code to parse the common, expected case.
- printer->Print("if (tag == $commontag$) {\n",
+ printer->Print("if (tag == $commontag$u) {\n",
"commontag", SimpleItoa(WireFormat::MakeTag(field)));
if (loops) {
@@ -3056,7 +3056,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
if (field->is_packed()) {
internal::WireFormatLite::WireType wiretype =
WireFormat::WireTypeForFieldType(field->type());
- printer->Print("} else if (tag == $uncommontag$) {\n",
+ printer->Print("} else if (tag == $uncommontag$u) {\n",
"uncommontag", SimpleItoa(
internal::WireFormatLite::MakeTag(
field->number(), wiretype)));
@@ -3066,7 +3066,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
} else if (field->is_packable() && !field->is_packed()) {
internal::WireFormatLite::WireType wiretype =
internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED;
- printer->Print("} else if (tag == $uncommontag$) {\n",
+ printer->Print("} else if (tag == $uncommontag$u) {\n",
"uncommontag", SimpleItoa(
internal::WireFormatLite::MakeTag(
field->number(), wiretype)));
diff --git a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
index 889271e9..240a6e0a 100644
--- a/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc
@@ -360,7 +360,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) const {
printer->Print(variables_,
"DO_((::google::protobuf::internal::WireFormatLite::$repeated_reader$<\n"
" $type$, $wire_format_field_type$>(\n"
- " $tag_size$, $tag$, input, this->mutable_$name$())));\n");
+ " $tag_size$, $tag$u, input, this->mutable_$name$())));\n");
}
void RepeatedPrimitiveFieldGenerator::