diff --git a/src/google/protobuf/compiler/cpp/generator.cc b/src/google/protobuf/compiler/cpp/generator.cc index 841785515f..952ef19c14 100644 --- a/src/google/protobuf/compiler/cpp/generator.cc +++ b/src/google/protobuf/compiler/cpp/generator.cc @@ -352,6 +352,8 @@ static bool IsEnumMapType(const FieldDescriptor& field) { absl::Status CppGenerator::ValidateFeatures(const FileDescriptor* file) const { absl::Status status = absl::OkStatus(); + auto edition = GetEdition(*file); + google::protobuf::internal::VisitDescriptors(*file, [&](const FieldDescriptor& field) { const FeatureSet& resolved_features = GetResolvedSourceFeatures(field); const pb::CppFeatures& unresolved_features = @@ -380,7 +382,8 @@ absl::Status CppGenerator::ValidateFeatures(const FileDescriptor* file) const { } } - if (field.options().has_ctype()) { + // 'ctype' check has moved to DescriptorBuilder for Edition 2023 and above. + if (edition < Edition::EDITION_2023 && field.options().has_ctype()) { if (field.cpp_type() != FieldDescriptor::CPPTYPE_STRING) { status = absl::FailedPreconditionError(absl::StrCat( "Field ", field.full_name(), diff --git a/src/google/protobuf/descriptor.cc b/src/google/protobuf/descriptor.cc index 5138f6024d..0cf7b75772 100644 --- a/src/google/protobuf/descriptor.cc +++ b/src/google/protobuf/descriptor.cc @@ -7664,8 +7664,6 @@ void DescriptorBuilder::ValidateOptions(const FieldDescriptor* field, ValidateFieldFeatures(field, proto); - // The following check is temporarily OSS only till we fix all affected - // google3 TAP tests. if (field->file()->edition() >= Edition::EDITION_2023 && field->options().has_ctype()) { if (field->cpp_type() != FieldDescriptor::CPPTYPE_STRING) {