diff --git a/protobuf/runtime/src/com/google/protobuf/GeneratedMessage.mm b/protobuf/runtime/src/com/google/protobuf/GeneratedMessage.mm index 3069a3deff..027c644dfd 100644 --- a/protobuf/runtime/src/com/google/protobuf/GeneratedMessage.mm +++ b/protobuf/runtime/src/com/google/protobuf/GeneratedMessage.mm @@ -1443,7 +1443,7 @@ static BOOL ReadMapEntryField( return stream->ReadRetainedNSString(&value->valueId); case ComGoogleProtobufDescriptors_FieldDescriptor_Type_Enum_GROUP: isGroup = YES; - // fall through. + FALLTHROUGH_INTENDED; case ComGoogleProtobufDescriptors_FieldDescriptor_Type_Enum_MESSAGE: { ComGoogleProtobufGeneratedMessage *newMsg = CGPNewMessage(field->valueType_); if (!(isGroup ? @@ -1554,7 +1554,7 @@ static BOOL MergeExtensionValueFromStream( return YES; case ComGoogleProtobufDescriptors_FieldDescriptor_Type_Enum_GROUP: isGroup = YES; - // fall through. + FALLTHROUGH_INTENDED; case ComGoogleProtobufDescriptors_FieldDescriptor_Type_Enum_MESSAGE: { CGPDescriptor *fieldType = field->valueType_; @@ -1806,7 +1806,7 @@ static BOOL MergeFieldFromStream( return YES; case ComGoogleProtobufDescriptors_FieldDescriptor_Type_Enum_GROUP: isGroup = YES; - // fall through. + FALLTHROUGH_INTENDED; case ComGoogleProtobufDescriptors_FieldDescriptor_Type_Enum_MESSAGE: { CGPDescriptor *fieldType = field->valueType_; diff --git a/protobuf/runtime/src/com/google/protobuf/common.h b/protobuf/runtime/src/com/google/protobuf/common.h index 4f6b5d89b4..f5d71d9889 100644 --- a/protobuf/runtime/src/com/google/protobuf/common.h +++ b/protobuf/runtime/src/com/google/protobuf/common.h @@ -46,4 +46,18 @@ typedef uint16_t uint16; typedef uint32_t uint32; typedef uint64_t uint64; +#if defined(__clang__) && defined(__has_warning) +#if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough") +#define FALLTHROUGH_INTENDED [[clang::fallthrough]] +#endif +#elif defined(__GNUC__) && __GNUC__ >= 7 +#define FALLTHROUGH_INTENDED [[gnu::fallthrough]] +#endif + +#ifndef FALLTHROUGH_INTENDED +#define FALLTHROUGH_INTENDED \ + do { \ + } while (0) +#endif + #endif // __ComGoogleProtobufCommon_H__