Marked compiler literal unsigned.

When compiling a protobuf with gcc 3.3.2 for powerpc, I ran into the
following warning message:

INFO: From Compiling my_proto.pb.cc powerpc-603e-linux-gcc:
bazel-out/local_linux-dbg/genfiles/my_proto.pb.cc: In member
   function `virtual void MyProto::Clear()':
   bazel-out/local_linux-dbg/genfiles/my_proto.pb.cc:223: warning: this
      decimal constant is unsigned only in ISO C90

The line in the proto file that was triggering it was:

  if (_has_bits_[24 / 32] & 4278190080) {
    ZR_(field1_, field2_);
  }

_has_bits_ is a uint32.  The constant mask should therefore be
unsigned.  This change updates the constant to be generated as
unsigned.
This commit is contained in:
Austin Schuh 2015-05-19 23:22:20 -07:00
parent 4324bf6bf2
commit e826837f7e
3 changed files with 16 additions and 16 deletions

View File

@ -2096,7 +2096,7 @@ GenerateClear(io::Printer* printer) {
} else { } else {
if (HasFieldPresence(descriptor_->file())) { if (HasFieldPresence(descriptor_->file())) {
printer->Print( printer->Print(
"if (_has_bits_[$index$ / 32] & $mask$) {\n", "if (_has_bits_[$index$ / 32] & $mask$u) {\n",
"index", SimpleItoa(i / 8 * 8), "index", SimpleItoa(i / 8 * 8),
"mask", SimpleItoa(mask)); "mask", SimpleItoa(mask));
printer->Indent(); printer->Indent();

View File

@ -724,7 +724,7 @@ CodeGeneratorResponse_File* CodeGeneratorResponse_File::New(::google::protobuf::
} }
void CodeGeneratorResponse_File::Clear() { void CodeGeneratorResponse_File::Clear() {
if (_has_bits_[0 / 32] & 7) { if (_has_bits_[0 / 32] & 7u) {
if (has_name()) { if (has_name()) {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
} }

View File

@ -1139,7 +1139,7 @@ FileDescriptorProto* FileDescriptorProto::New(::google::protobuf::Arena* arena)
} }
void FileDescriptorProto::Clear() { void FileDescriptorProto::Clear() {
if (_has_bits_[0 / 32] & 3) { if (_has_bits_[0 / 32] & 3u) {
if (has_name()) { if (has_name()) {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
} }
@ -1147,7 +1147,7 @@ void FileDescriptorProto::Clear() {
package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
} }
} }
if (_has_bits_[8 / 32] & 3584) { if (_has_bits_[8 / 32] & 3584u) {
if (has_options()) { if (has_options()) {
if (options_ != NULL) options_->::google::protobuf::FileOptions::Clear(); if (options_ != NULL) options_->::google::protobuf::FileOptions::Clear();
} }
@ -2656,7 +2656,7 @@ DescriptorProto* DescriptorProto::New(::google::protobuf::Arena* arena) const {
} }
void DescriptorProto::Clear() { void DescriptorProto::Clear() {
if (_has_bits_[0 / 32] & 129) { if (_has_bits_[0 / 32] & 129u) {
if (has_name()) { if (has_name()) {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
} }
@ -3613,7 +3613,7 @@ FieldDescriptorProto* FieldDescriptorProto::New(::google::protobuf::Arena* arena
} }
void FieldDescriptorProto::Clear() { void FieldDescriptorProto::Clear() {
if (_has_bits_[0 / 32] & 255) { if (_has_bits_[0 / 32] & 255u) {
if (has_name()) { if (has_name()) {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
} }
@ -4898,7 +4898,7 @@ EnumDescriptorProto* EnumDescriptorProto::New(::google::protobuf::Arena* arena)
} }
void EnumDescriptorProto::Clear() { void EnumDescriptorProto::Clear() {
if (_has_bits_[0 / 32] & 5) { if (_has_bits_[0 / 32] & 5u) {
if (has_name()) { if (has_name()) {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
} }
@ -5369,7 +5369,7 @@ EnumValueDescriptorProto* EnumValueDescriptorProto::New(::google::protobuf::Aren
} }
void EnumValueDescriptorProto::Clear() { void EnumValueDescriptorProto::Clear() {
if (_has_bits_[0 / 32] & 7) { if (_has_bits_[0 / 32] & 7u) {
if (has_name()) { if (has_name()) {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
} }
@ -5831,7 +5831,7 @@ ServiceDescriptorProto* ServiceDescriptorProto::New(::google::protobuf::Arena* a
} }
void ServiceDescriptorProto::Clear() { void ServiceDescriptorProto::Clear() {
if (_has_bits_[0 / 32] & 5) { if (_has_bits_[0 / 32] & 5u) {
if (has_name()) { if (has_name()) {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
} }
@ -6318,7 +6318,7 @@ void MethodDescriptorProto::Clear() {
ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
} while (0) } while (0)
if (_has_bits_[0 / 32] & 63) { if (_has_bits_[0 / 32] & 63u) {
ZR_(client_streaming_, server_streaming_); ZR_(client_streaming_, server_streaming_);
if (has_name()) { if (has_name()) {
name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); name_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@ -7110,7 +7110,7 @@ void FileOptions::Clear() {
ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
} while (0) } while (0)
if (_has_bits_[0 / 32] & 255) { if (_has_bits_[0 / 32] & 255u) {
ZR_(java_multiple_files_, cc_generic_services_); ZR_(java_multiple_files_, cc_generic_services_);
if (has_java_package()) { if (has_java_package()) {
java_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); java_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@ -7123,7 +7123,7 @@ void FileOptions::Clear() {
go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); go_package_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
} }
} }
if (_has_bits_[8 / 32] & 16128) { if (_has_bits_[8 / 32] & 16128u) {
ZR_(java_generic_services_, cc_enable_arenas_); ZR_(java_generic_services_, cc_enable_arenas_);
if (has_objc_class_prefix()) { if (has_objc_class_prefix()) {
objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); objc_class_prefix_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@ -9054,7 +9054,7 @@ void FieldOptions::Clear() {
ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
} while (0) } while (0)
if (_has_bits_[0 / 32] & 31) { if (_has_bits_[0 / 32] & 31u) {
ZR_(ctype_, weak_); ZR_(ctype_, weak_);
} }
@ -11109,7 +11109,7 @@ UninterpretedOption_NamePart* UninterpretedOption_NamePart::New(::google::protob
} }
void UninterpretedOption_NamePart::Clear() { void UninterpretedOption_NamePart::Clear() {
if (_has_bits_[0 / 32] & 3) { if (_has_bits_[0 / 32] & 3u) {
if (has_name_part()) { if (has_name_part()) {
name_part_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); name_part_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
} }
@ -11434,7 +11434,7 @@ void UninterpretedOption::Clear() {
ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\ ZR_HELPER_(last) - ZR_HELPER_(first) + sizeof(last));\
} while (0) } while (0)
if (_has_bits_[0 / 32] & 126) { if (_has_bits_[0 / 32] & 126u) {
ZR_(positive_int_value_, double_value_); ZR_(positive_int_value_, double_value_);
if (has_identifier_value()) { if (has_identifier_value()) {
identifier_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); identifier_value_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
@ -12284,7 +12284,7 @@ SourceCodeInfo_Location* SourceCodeInfo_Location::New(::google::protobuf::Arena*
} }
void SourceCodeInfo_Location::Clear() { void SourceCodeInfo_Location::Clear() {
if (_has_bits_[0 / 32] & 12) { if (_has_bits_[0 / 32] & 12u) {
if (has_leading_comments()) { if (has_leading_comments()) {
leading_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited()); leading_comments_.ClearToEmptyNoArena(&::google::protobuf::internal::GetEmptyStringAlreadyInited());
} }