aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/compiler/cpp/cpp_message.cc
diff options
context:
space:
mode:
authorJisi Liu <jisi.liu@gmail.com>2017-08-03 11:13:25 -0700
committerJisi Liu <jisi.liu@gmail.com>2017-08-03 11:13:25 -0700
commit4cbbf33b773fb95aa339ee50517fd375f5120ffe (patch)
tree7b747f7af11853481922d327fc15de93f6d9b154 /src/google/protobuf/compiler/cpp/cpp_message.cc
parent778178479626b0e5b4de0701103a1bb0a067702d (diff)
downloadprotobuf-4cbbf33b773fb95aa339ee50517fd375f5120ffe.tar.gz
protobuf-4cbbf33b773fb95aa339ee50517fd375f5120ffe.tar.bz2
protobuf-4cbbf33b773fb95aa339ee50517fd375f5120ffe.zip
Fix invalid offsetof warning.
Use composition instead of inheritance for oneof default.
Diffstat (limited to 'src/google/protobuf/compiler/cpp/cpp_message.cc')
-rw-r--r--src/google/protobuf/compiler/cpp/cpp_message.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/google/protobuf/compiler/cpp/cpp_message.cc b/src/google/protobuf/compiler/cpp/cpp_message.cc
index abb2e95a..36cbf5d7 100644
--- a/src/google/protobuf/compiler/cpp/cpp_message.cc
+++ b/src/google/protobuf/compiler/cpp/cpp_message.cc
@@ -1604,7 +1604,6 @@ GenerateExtraDefaultFields(io::Printer* printer) {
// Generate oneof default instance and weak field instances for reflection
// usage.
if (descriptor_->oneof_decl_count() > 0 || num_weak_fields_ > 0) {
- printer->Print("public:\n");
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
for (int j = 0; j < descriptor_->oneof_decl(i)->field_count(); j++) {
const FieldDescriptor* field = descriptor_->oneof_decl(i)->field(j);
@@ -1977,7 +1976,7 @@ GenerateDefaultInstanceAllocator(io::Printer* printer) {
// Construct the default instance. We can't call InitAsDefaultInstance() yet
// because we need to make sure all default instances that this one might
// depend on are constructed first.
- printer->Print("_$classname$_default_instance_.DefaultConstruct();\n"
+ printer->Print("_$classname$_default_instance_._instance.DefaultConstruct();\n"
"::google::protobuf::internal::OnShutdownDestroyMessage(\n"
" &_$classname$_default_instance_);",
"classname", classname_);
@@ -1987,9 +1986,9 @@ void MessageGenerator::
GenerateDefaultInstanceInitializer(io::Printer* printer) {
if (IsMapEntryMessage(descriptor_)) {
printer->Print(
- "_$classname$_default_instance_.get_mutable()->set_default_instance(_$"
- "classname$_default_instance_.get_mutable());\n"
- "_$classname$_default_instance_.get_mutable()->InitAsDefaultInstance();"
+ "_$classname$_default_instance_._instance.get_mutable()->set_default_instance(_$"
+ "classname$_default_instance_._instance.get_mutable());\n"
+ "_$classname$_default_instance_._instance.get_mutable()->InitAsDefaultInstance();"
"\n",
"classname", classname_);
return;
@@ -2012,7 +2011,8 @@ GenerateDefaultInstanceInitializer(io::Printer* printer) {
if (field->containing_oneof() || field->options().weak()) {
name = "_" + classname_ + "_default_instance_.";
} else {
- name = "_" + classname_ + "_default_instance_.get_mutable()->";
+ name =
+ "_" + classname_ + "_default_instance_._instance.get_mutable()->";
}
name += FieldName(field);
printer->Print(