Skip to content

Commit

Permalink
Merge pull request protocolbuffers#15641 from mkruskal-google/backport
Browse files Browse the repository at this point in the history
Check ctype() in DescriptorBuilder for edition 2023 and beyond.
  • Loading branch information
mkruskal-google authored Jan 30, 2024
2 parents 68604e8 + 0090f19 commit 77efb8d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/google/protobuf/descriptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7723,7 +7723,8 @@ void DescriptorBuilder::ValidateOptions(const FieldDescriptor* field,

// The following check is temporarily OSS only till we fix all affected
// google3 TAP tests.
if (field->options().has_ctype()) {
if (field->file()->edition() >= Edition::EDITION_2023 &&
field->options().has_ctype()) {
if (field->cpp_type() != FieldDescriptor::CPPTYPE_STRING) {
AddError(
field->full_name(), proto, DescriptorPool::ErrorCollector::TYPE,
Expand Down
3 changes: 3 additions & 0 deletions src/google/protobuf/descriptor_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2947,6 +2947,9 @@ TEST_F(MiscTest, InvalidFieldOptions) {
FileDescriptorProto file_proto;
file_proto.set_name("foo.proto");

file_proto.set_syntax("editions");
file_proto.set_edition(Edition::EDITION_2023);

DescriptorProto* message_proto = AddMessage(&file_proto, "TestMessage");
AddField(message_proto, "foo", 1, FieldDescriptorProto::LABEL_OPTIONAL,
FieldDescriptorProto::TYPE_INT32);
Expand Down

0 comments on commit 77efb8d

Please sign in to comment.