fix(cpp): suppress self-warning on deprecated enum value imports (#28012)#28185
Merged
Conversation
9cb5abb to
52cf19b
Compare
) Fixes #18205. protoc generates a class-scoped alias for each nested enum value (for example `static constexpr Status OK = Result_Status_OK;`). For a value marked `[deprecated = true]`, the alias is itself `[[deprecated]]` and initializes from the deprecated enumerator, so protoc's own generated header trips `-Wdeprecated-declarations`. That breaks downstream builds compiled with `-Werror`, even though the user does not control the generated code. This wraps the alias in the existing `PROTOBUF_IGNORE_DEPRECATION_START`/`PROTOBUF_IGNORE_DEPRECATION_STOP` macros, as suggested by a maintainer on the issue. Non-deprecated values are unchanged. Test: added two cases to `generator_unittest.cc` (one asserting the wrap is emitted for a deprecated value, one asserting no macro is emitted otherwise). ./build/tests --gtest_filter='CppGeneratorTest.*' Result: all CppGeneratorTest cases pass (including the two new ones). Closes #28012 COPYBARA_INTEGRATE_REVIEW=#28012 from yashanil98:fix/issue-18205-enum-symbol-import-deprecation 2cad7bc PiperOrigin-RevId: 938705268
52cf19b to
69f97e0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(cpp): suppress self-warning on deprecated enum value imports (#28012)
Fixes #18205.
protoc generates a class-scoped alias for each nested enum value (for example
static constexpr Status OK = Result_Status_OK;). For a value marked[deprecated = true], the alias is itself[[deprecated]]and initializes from the deprecated enumerator, so protoc's own generated header trips-Wdeprecated-declarations. That breaks downstream builds compiled with-Werror, even though the user does not control the generated code. This wraps the alias in the existingPROTOBUF_IGNORE_DEPRECATION_START/PROTOBUF_IGNORE_DEPRECATION_STOPmacros, as suggested by a maintainer on the issue. Non-deprecated values are unchanged.Test: added two cases to
generator_unittest.cc(one asserting the wrap is emitted for a deprecated value, one asserting no macro is emitted otherwise)../build/tests --gtest_filter='CppGeneratorTest.*'
Result: all CppGeneratorTest cases pass (including the two new ones).
Closes #28012
COPYBARA_INTEGRATE_REVIEW=#28012 from yashanil98:fix/issue-18205-enum-symbol-import-deprecation 2cad7bc
FUTURE_COPYBARA_INTEGRATE_REVIEW=#28012 from yashanil98:fix/issue-18205-enum-symbol-import-deprecation 2cad7bc