Commit 573989f7 authored by kenton@google.com's avatar kenton@google.com

Explicitly call superclass constructor in generated code to avoid pedantic…

Explicitly call superclass constructor in generated code to avoid pedantic warning.  Based on patch from Oleg Smolsky.
parent 1a4193c2
...@@ -833,12 +833,17 @@ GenerateSharedDestructorCode(io::Printer* printer) { ...@@ -833,12 +833,17 @@ GenerateSharedDestructorCode(io::Printer* printer) {
void MessageGenerator:: void MessageGenerator::
GenerateStructors(io::Printer* printer) { GenerateStructors(io::Printer* printer) {
string superclass = HasDescriptorMethods(descriptor_->file()) ?
"Message" : "MessageLite";
// Generate the default constructor. // Generate the default constructor.
printer->Print( printer->Print(
"$classname$::$classname$() {\n" "$classname$::$classname$()\n"
" : $superclass$() {\n"
" SharedCtor();\n" " SharedCtor();\n"
"}\n", "}\n",
"classname", classname_); "classname", classname_,
"superclass", superclass);
printer->Print( printer->Print(
"\n" "\n"
...@@ -868,12 +873,14 @@ GenerateStructors(io::Printer* printer) { ...@@ -868,12 +873,14 @@ GenerateStructors(io::Printer* printer) {
// Generate the copy constructor. // Generate the copy constructor.
printer->Print( printer->Print(
"$classname$::$classname$(const $classname$& from) {\n" "$classname$::$classname$(const $classname$& from)\n"
" : $superclass$() {\n"
" SharedCtor();\n" " SharedCtor();\n"
" MergeFrom(from);\n" " MergeFrom(from);\n"
"}\n" "}\n"
"\n", "\n",
"classname", classname_); "classname", classname_,
"superclass", superclass);
// Generate the shared constructor code. // Generate the shared constructor code.
GenerateSharedConstructorCode(printer); GenerateSharedConstructorCode(printer);
......
...@@ -644,14 +644,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fdescriptor_2eproto { ...@@ -644,14 +644,16 @@ struct StaticDescriptorInitializer_google_2fprotobuf_2fdescriptor_2eproto {
const int FileDescriptorSet::kFileFieldNumber; const int FileDescriptorSet::kFileFieldNumber;
#endif // !_MSC_VER #endif // !_MSC_VER
FileDescriptorSet::FileDescriptorSet() { FileDescriptorSet::FileDescriptorSet()
: Message() {
SharedCtor(); SharedCtor();
} }
void FileDescriptorSet::InitAsDefaultInstance() { void FileDescriptorSet::InitAsDefaultInstance() {
} }
FileDescriptorSet::FileDescriptorSet(const FileDescriptorSet& from) { FileDescriptorSet::FileDescriptorSet(const FileDescriptorSet& from)
: Message() {
SharedCtor(); SharedCtor();
MergeFrom(from); MergeFrom(from);
} }
...@@ -854,7 +856,8 @@ const int FileDescriptorProto::kExtensionFieldNumber; ...@@ -854,7 +856,8 @@ const int FileDescriptorProto::kExtensionFieldNumber;
const int FileDescriptorProto::kOptionsFieldNumber; const int FileDescriptorProto::kOptionsFieldNumber;
#endif // !_MSC_VER #endif // !_MSC_VER
FileDescriptorProto::FileDescriptorProto() { FileDescriptorProto::FileDescriptorProto()
: Message() {
SharedCtor(); SharedCtor();
} }
...@@ -862,7 +865,8 @@ void FileDescriptorProto::InitAsDefaultInstance() { ...@@ -862,7 +865,8 @@ void FileDescriptorProto::InitAsDefaultInstance() {
options_ = const_cast< ::google::protobuf::FileOptions*>(&::google::protobuf::FileOptions::default_instance()); options_ = const_cast< ::google::protobuf::FileOptions*>(&::google::protobuf::FileOptions::default_instance());
} }
FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from) { FileDescriptorProto::FileDescriptorProto(const FileDescriptorProto& from)
: Message() {
SharedCtor(); SharedCtor();
MergeFrom(from); MergeFrom(from);
} }
...@@ -1385,14 +1389,16 @@ const int DescriptorProto_ExtensionRange::kStartFieldNumber; ...@@ -1385,14 +1389,16 @@ const int DescriptorProto_ExtensionRange::kStartFieldNumber;
const int DescriptorProto_ExtensionRange::kEndFieldNumber; const int DescriptorProto_ExtensionRange::kEndFieldNumber;
#endif // !_MSC_VER #endif // !_MSC_VER
DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange() { DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange()
: Message() {
SharedCtor(); SharedCtor();
} }
void DescriptorProto_ExtensionRange::InitAsDefaultInstance() { void DescriptorProto_ExtensionRange::InitAsDefaultInstance() {
} }
DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from) { DescriptorProto_ExtensionRange::DescriptorProto_ExtensionRange(const DescriptorProto_ExtensionRange& from)
: Message() {
SharedCtor(); SharedCtor();
MergeFrom(from); MergeFrom(from);
} }
...@@ -1631,7 +1637,8 @@ const int DescriptorProto::kExtensionRangeFieldNumber; ...@@ -1631,7 +1637,8 @@ const int DescriptorProto::kExtensionRangeFieldNumber;
const int DescriptorProto::kOptionsFieldNumber; const int DescriptorProto::kOptionsFieldNumber;
#endif // !_MSC_VER #endif // !_MSC_VER
DescriptorProto::DescriptorProto() { DescriptorProto::DescriptorProto()
: Message() {
SharedCtor(); SharedCtor();
} }
...@@ -1639,7 +1646,8 @@ void DescriptorProto::InitAsDefaultInstance() { ...@@ -1639,7 +1646,8 @@ void DescriptorProto::InitAsDefaultInstance() {
options_ = const_cast< ::google::protobuf::MessageOptions*>(&::google::protobuf::MessageOptions::default_instance()); options_ = const_cast< ::google::protobuf::MessageOptions*>(&::google::protobuf::MessageOptions::default_instance());
} }
DescriptorProto::DescriptorProto(const DescriptorProto& from) { DescriptorProto::DescriptorProto(const DescriptorProto& from)
: Message() {
SharedCtor(); SharedCtor();
MergeFrom(from); MergeFrom(from);
} }
...@@ -2184,7 +2192,8 @@ const int FieldDescriptorProto::kDefaultValueFieldNumber; ...@@ -2184,7 +2192,8 @@ const int FieldDescriptorProto::kDefaultValueFieldNumber;
const int FieldDescriptorProto::kOptionsFieldNumber; const int FieldDescriptorProto::kOptionsFieldNumber;
#endif // !_MSC_VER #endif // !_MSC_VER
FieldDescriptorProto::FieldDescriptorProto() { FieldDescriptorProto::FieldDescriptorProto()
: Message() {
SharedCtor(); SharedCtor();
} }
...@@ -2192,7 +2201,8 @@ void FieldDescriptorProto::InitAsDefaultInstance() { ...@@ -2192,7 +2201,8 @@ void FieldDescriptorProto::InitAsDefaultInstance() {
options_ = const_cast< ::google::protobuf::FieldOptions*>(&::google::protobuf::FieldOptions::default_instance()); options_ = const_cast< ::google::protobuf::FieldOptions*>(&::google::protobuf::FieldOptions::default_instance());
} }
FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from) { FieldDescriptorProto::FieldDescriptorProto(const FieldDescriptorProto& from)
: Message() {
SharedCtor(); SharedCtor();
MergeFrom(from); MergeFrom(from);
} }
...@@ -2739,7 +2749,8 @@ const int EnumDescriptorProto::kValueFieldNumber; ...@@ -2739,7 +2749,8 @@ const int EnumDescriptorProto::kValueFieldNumber;
const int EnumDescriptorProto::kOptionsFieldNumber; const int EnumDescriptorProto::kOptionsFieldNumber;
#endif // !_MSC_VER #endif // !_MSC_VER
EnumDescriptorProto::EnumDescriptorProto() { EnumDescriptorProto::EnumDescriptorProto()
: Message() {
SharedCtor(); SharedCtor();
} }
...@@ -2747,7 +2758,8 @@ void EnumDescriptorProto::InitAsDefaultInstance() { ...@@ -2747,7 +2758,8 @@ void EnumDescriptorProto::InitAsDefaultInstance() {
options_ = const_cast< ::google::protobuf::EnumOptions*>(&::google::protobuf::EnumOptions::default_instance()); options_ = const_cast< ::google::protobuf::EnumOptions*>(&::google::protobuf::EnumOptions::default_instance());
} }
EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from) { EnumDescriptorProto::EnumDescriptorProto(const EnumDescriptorProto& from)
: Message() {
SharedCtor(); SharedCtor();
MergeFrom(from); MergeFrom(from);
} }
...@@ -3049,7 +3061,8 @@ const int EnumValueDescriptorProto::kNumberFieldNumber; ...@@ -3049,7 +3061,8 @@ const int EnumValueDescriptorProto::kNumberFieldNumber;
const int EnumValueDescriptorProto::kOptionsFieldNumber; const int EnumValueDescriptorProto::kOptionsFieldNumber;
#endif // !_MSC_VER #endif // !_MSC_VER
EnumValueDescriptorProto::EnumValueDescriptorProto() { EnumValueDescriptorProto::EnumValueDescriptorProto()
: Message() {
SharedCtor(); SharedCtor();
} }
...@@ -3057,7 +3070,8 @@ void EnumValueDescriptorProto::InitAsDefaultInstance() { ...@@ -3057,7 +3070,8 @@ void EnumValueDescriptorProto::InitAsDefaultInstance() {
options_ = const_cast< ::google::protobuf::EnumValueOptions*>(&::google::protobuf::EnumValueOptions::default_instance()); options_ = const_cast< ::google::protobuf::EnumValueOptions*>(&::google::protobuf::EnumValueOptions::default_instance());
} }
EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProto& from) { EnumValueDescriptorProto::EnumValueDescriptorProto(const EnumValueDescriptorProto& from)
: Message() {
SharedCtor(); SharedCtor();
MergeFrom(from); MergeFrom(from);
} }
...@@ -3355,7 +3369,8 @@ const int ServiceDescriptorProto::kMethodFieldNumber; ...@@ -3355,7 +3369,8 @@ const int ServiceDescriptorProto::kMethodFieldNumber;
const int ServiceDescriptorProto::kOptionsFieldNumber; const int ServiceDescriptorProto::kOptionsFieldNumber;
#endif // !_MSC_VER #endif // !_MSC_VER
ServiceDescriptorProto::ServiceDescriptorProto() { ServiceDescriptorProto::ServiceDescriptorProto()
: Message() {
SharedCtor(); SharedCtor();
} }
...@@ -3363,7 +3378,8 @@ void ServiceDescriptorProto::InitAsDefaultInstance() { ...@@ -3363,7 +3378,8 @@ void ServiceDescriptorProto::InitAsDefaultInstance() {
options_ = const_cast< ::google::protobuf::ServiceOptions*>(&::google::protobuf::ServiceOptions::default_instance()); options_ = const_cast< ::google::protobuf::ServiceOptions*>(&::google::protobuf::ServiceOptions::default_instance());
} }
ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& from) { ServiceDescriptorProto::ServiceDescriptorProto(const ServiceDescriptorProto& from)
: Message() {
SharedCtor(); SharedCtor();
MergeFrom(from); MergeFrom(from);
} }
...@@ -3668,7 +3684,8 @@ const int MethodDescriptorProto::kOutputTypeFieldNumber; ...@@ -3668,7 +3684,8 @@ const int MethodDescriptorProto::kOutputTypeFieldNumber;
const int MethodDescriptorProto::kOptionsFieldNumber; const int MethodDescriptorProto::kOptionsFieldNumber;
#endif // !_MSC_VER #endif // !_MSC_VER
MethodDescriptorProto::MethodDescriptorProto() { MethodDescriptorProto::MethodDescriptorProto()
: Message() {
SharedCtor(); SharedCtor();
} }
...@@ -3676,7 +3693,8 @@ void MethodDescriptorProto::InitAsDefaultInstance() { ...@@ -3676,7 +3693,8 @@ void MethodDescriptorProto::InitAsDefaultInstance() {
options_ = const_cast< ::google::protobuf::MethodOptions*>(&::google::protobuf::MethodOptions::default_instance()); options_ = const_cast< ::google::protobuf::MethodOptions*>(&::google::protobuf::MethodOptions::default_instance());
} }
MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from) { MethodDescriptorProto::MethodDescriptorProto(const MethodDescriptorProto& from)
: Message() {
SharedCtor(); SharedCtor();
MergeFrom(from); MergeFrom(from);
} }
...@@ -4072,14 +4090,16 @@ const int FileOptions::kOptimizeForFieldNumber; ...@@ -4072,14 +4090,16 @@ const int FileOptions::kOptimizeForFieldNumber;
const int FileOptions::kUninterpretedOptionFieldNumber; const int FileOptions::kUninterpretedOptionFieldNumber;
#endif // !_MSC_VER #endif // !_MSC_VER
FileOptions::FileOptions() { FileOptions::FileOptions()
: Message() {
SharedCtor(); SharedCtor();
} }
void FileOptions::InitAsDefaultInstance() { void FileOptions::InitAsDefaultInstance() {
} }
FileOptions::FileOptions(const FileOptions& from) { FileOptions::FileOptions(const FileOptions& from)
: Message() {
SharedCtor(); SharedCtor();
MergeFrom(from); MergeFrom(from);
} }
...@@ -4486,14 +4506,16 @@ const int MessageOptions::kNoStandardDescriptorAccessorFieldNumber; ...@@ -4486,14 +4506,16 @@ const int MessageOptions::kNoStandardDescriptorAccessorFieldNumber;
const int MessageOptions::kUninterpretedOptionFieldNumber; const int MessageOptions::kUninterpretedOptionFieldNumber;
#endif // !_MSC_VER #endif // !_MSC_VER
MessageOptions::MessageOptions() { MessageOptions::MessageOptions()
: Message() {
SharedCtor(); SharedCtor();
} }
void MessageOptions::InitAsDefaultInstance() { void MessageOptions::InitAsDefaultInstance() {
} }
MessageOptions::MessageOptions(const MessageOptions& from) { MessageOptions::MessageOptions(const MessageOptions& from)
: Message() {
SharedCtor(); SharedCtor();
MergeFrom(from); MergeFrom(from);
} }
...@@ -4806,14 +4828,16 @@ const int FieldOptions::kExperimentalMapKeyFieldNumber; ...@@ -4806,14 +4828,16 @@ const int FieldOptions::kExperimentalMapKeyFieldNumber;
const int FieldOptions::kUninterpretedOptionFieldNumber; const int FieldOptions::kUninterpretedOptionFieldNumber;
#endif // !_MSC_VER #endif // !_MSC_VER
FieldOptions::FieldOptions() { FieldOptions::FieldOptions()
: Message() {
SharedCtor(); SharedCtor();
} }
void FieldOptions::InitAsDefaultInstance() { void FieldOptions::InitAsDefaultInstance() {
} }
FieldOptions::FieldOptions(const FieldOptions& from) { FieldOptions::FieldOptions(const FieldOptions& from)
: Message() {
SharedCtor(); SharedCtor();
MergeFrom(from); MergeFrom(from);
} }
...@@ -5198,14 +5222,16 @@ void FieldOptions::Swap(FieldOptions* other) { ...@@ -5198,14 +5222,16 @@ void FieldOptions::Swap(FieldOptions* other) {
const int EnumOptions::kUninterpretedOptionFieldNumber; const int EnumOptions::kUninterpretedOptionFieldNumber;
#endif // !_MSC_VER #endif // !_MSC_VER
EnumOptions::EnumOptions() { EnumOptions::EnumOptions()
: Message() {
SharedCtor(); SharedCtor();
} }
void EnumOptions::InitAsDefaultInstance() { void EnumOptions::InitAsDefaultInstance() {
} }
EnumOptions::EnumOptions(const EnumOptions& from) { EnumOptions::EnumOptions(const EnumOptions& from)
: Message() {
SharedCtor(); SharedCtor();
MergeFrom(from); MergeFrom(from);
} }
...@@ -5418,14 +5444,16 @@ void EnumOptions::Swap(EnumOptions* other) { ...@@ -5418,14 +5444,16 @@ void EnumOptions::Swap(EnumOptions* other) {
const int EnumValueOptions::kUninterpretedOptionFieldNumber; const int EnumValueOptions::kUninterpretedOptionFieldNumber;
#endif // !_MSC_VER #endif // !_MSC_VER
EnumValueOptions::EnumValueOptions() { EnumValueOptions::EnumValueOptions()
: Message() {
SharedCtor(); SharedCtor();
} }
void EnumValueOptions::InitAsDefaultInstance() { void EnumValueOptions::InitAsDefaultInstance() {
} }
EnumValueOptions::EnumValueOptions(const EnumValueOptions& from) { EnumValueOptions::EnumValueOptions(const EnumValueOptions& from)
: Message() {
SharedCtor(); SharedCtor();
MergeFrom(from); MergeFrom(from);
} }
...@@ -5638,14 +5666,16 @@ void EnumValueOptions::Swap(EnumValueOptions* other) { ...@@ -5638,14 +5666,16 @@ void EnumValueOptions::Swap(EnumValueOptions* other) {
const int ServiceOptions::kUninterpretedOptionFieldNumber; const int ServiceOptions::kUninterpretedOptionFieldNumber;
#endif // !_MSC_VER #endif // !_MSC_VER
ServiceOptions::ServiceOptions() { ServiceOptions::ServiceOptions()
: Message() {
SharedCtor(); SharedCtor();
} }
void ServiceOptions::InitAsDefaultInstance() { void ServiceOptions::InitAsDefaultInstance() {
} }
ServiceOptions::ServiceOptions(const ServiceOptions& from) { ServiceOptions::ServiceOptions(const ServiceOptions& from)
: Message() {
SharedCtor(); SharedCtor();
MergeFrom(from); MergeFrom(from);
} }
...@@ -5858,14 +5888,16 @@ void ServiceOptions::Swap(ServiceOptions* other) { ...@@ -5858,14 +5888,16 @@ void ServiceOptions::Swap(ServiceOptions* other) {
const int MethodOptions::kUninterpretedOptionFieldNumber; const int MethodOptions::kUninterpretedOptionFieldNumber;
#endif // !_MSC_VER #endif // !_MSC_VER
MethodOptions::MethodOptions() { MethodOptions::MethodOptions()
: Message() {
SharedCtor(); SharedCtor();
} }
void MethodOptions::InitAsDefaultInstance() { void MethodOptions::InitAsDefaultInstance() {
} }
MethodOptions::MethodOptions(const MethodOptions& from) { MethodOptions::MethodOptions(const MethodOptions& from)
: Message() {
SharedCtor(); SharedCtor();
MergeFrom(from); MergeFrom(from);
} }
...@@ -6080,14 +6112,16 @@ const int UninterpretedOption_NamePart::kNamePartFieldNumber; ...@@ -6080,14 +6112,16 @@ const int UninterpretedOption_NamePart::kNamePartFieldNumber;
const int UninterpretedOption_NamePart::kIsExtensionFieldNumber; const int UninterpretedOption_NamePart::kIsExtensionFieldNumber;
#endif // !_MSC_VER #endif // !_MSC_VER
UninterpretedOption_NamePart::UninterpretedOption_NamePart() { UninterpretedOption_NamePart::UninterpretedOption_NamePart()
: Message() {
SharedCtor(); SharedCtor();
} }
void UninterpretedOption_NamePart::InitAsDefaultInstance() { void UninterpretedOption_NamePart::InitAsDefaultInstance() {
} }
UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from) { UninterpretedOption_NamePart::UninterpretedOption_NamePart(const UninterpretedOption_NamePart& from)
: Message() {
SharedCtor(); SharedCtor();
MergeFrom(from); MergeFrom(from);
} }
...@@ -6343,14 +6377,16 @@ const int UninterpretedOption::kDoubleValueFieldNumber; ...@@ -6343,14 +6377,16 @@ const int UninterpretedOption::kDoubleValueFieldNumber;
const int UninterpretedOption::kStringValueFieldNumber; const int UninterpretedOption::kStringValueFieldNumber;
#endif // !_MSC_VER #endif // !_MSC_VER
UninterpretedOption::UninterpretedOption() { UninterpretedOption::UninterpretedOption()
: Message() {
SharedCtor(); SharedCtor();
} }
void UninterpretedOption::InitAsDefaultInstance() { void UninterpretedOption::InitAsDefaultInstance() {
} }
UninterpretedOption::UninterpretedOption(const UninterpretedOption& from) { UninterpretedOption::UninterpretedOption(const UninterpretedOption& from)
: Message() {
SharedCtor(); SharedCtor();
MergeFrom(from); MergeFrom(from);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment