Skip to content

Commit

Permalink
Build with -Wundef (#17845)
Browse files Browse the repository at this point in the history
This allows downstream consumers of protobuf to enable Wundef in their code which consumes protobuf APIs.

Closes #17845

COPYBARA_INTEGRATE_REVIEW=#17845 from cramertj:wundef 8750f8c
PiperOrigin-RevId: 700721632
  • Loading branch information
cramertj authored and copybara-github committed Nov 27, 2024
1 parent 7588e51 commit 653f511
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions ci/Linux.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ import common.bazelrc

build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
build --cxxopt="-Woverloaded-virtual"
build --copt="-Wpointer-arith"
build --copt="-Werror" --copt="-Wno-sign-compare" --copt="-Wno-sign-conversion" --copt="-Wno-error=sign-conversion" --copt="-Wno-deprecated-declarations"

1 change: 1 addition & 0 deletions ci/macOS.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import common.bazelrc

build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
build --cxxopt="-Woverloaded-virtual"
build --copt="-Wpointer-arith"
build --copt="-Werror" --copt="-Wno-sign-compare" --copt="-Wno-sign-conversion" --copt="-Wno-error=sign-conversion" --copt="-Wno-deprecated-declarations"
common --repo_env=BAZEL_NO_APPLE_CPP_TOOLCHAIN=1
common --xcode_version_config=@com_google_protobuf//.github:host_xcodes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ using google::protobuf::io::win32::write;

// Disable the whole test when we use tcmalloc for "draconian" heap checks, in
// which case tcmalloc will print warnings that fail the plugin tests.
#if !GOOGLE_PROTOBUF_HEAP_CHECK_DRACONIAN
#if !defined(GOOGLE_PROTOBUF_HEAP_CHECK_DRACONIAN)


namespace {
Expand Down
4 changes: 2 additions & 2 deletions src/google/protobuf/message_lite.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ class PROTOBUF_EXPORT CachedSize {
// NOLINTNEXTLINE(google-explicit-constructor)
constexpr CachedSize(Scalar desired) noexcept : atom_(desired) {}

#if PROTOBUF_BUILTIN_ATOMIC
#ifdef PROTOBUF_BUILTIN_ATOMIC
constexpr CachedSize(const CachedSize& other) = default;

Scalar Get() const noexcept {
Expand Down Expand Up @@ -233,7 +233,7 @@ class PROTOBUF_EXPORT CachedSize {
#endif

private:
#if PROTOBUF_BUILTIN_ATOMIC
#ifdef PROTOBUF_BUILTIN_ATOMIC
mutable Scalar atom_;
#else
mutable std::atomic<Scalar> atom_;
Expand Down
2 changes: 1 addition & 1 deletion upb/message/internal/message.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ bool UPB_PRIVATE(_upb_Message_EnsureAvailable)(struct upb_Message* msg,
return true;
}

#if UPB_TRACING_ENABLED
#ifdef UPB_TRACING_ENABLED
static void (*_message_trace_handler)(const upb_MiniTable*, const upb_Arena*);

void upb_Message_LogNewMessage(const upb_MiniTable* m, const upb_Arena* arena) {
Expand Down
2 changes: 1 addition & 1 deletion upb/mini_descriptor/decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,7 @@ static upb_MiniTable* upb_MtDecoder_DoBuildMiniTableWithBuf(
decoder->table->UPB_PRIVATE(dense_below) = 0;
decoder->table->UPB_PRIVATE(table_mask) = -1;
decoder->table->UPB_PRIVATE(required_count) = 0;
#if UPB_TRACING_ENABLED
#ifdef UPB_TRACING_ENABLED
// MiniTables built from MiniDescriptors will not be able to vend the message
// name unless it is explicitly set with upb_MiniTable_SetFullName().
decoder->table->UPB_PRIVATE(full_name) = 0;
Expand Down
2 changes: 1 addition & 1 deletion upb/reflection/descriptor_bootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#if defined(UPB_BOOTSTRAP_STAGE) && UPB_BOOTSTRAP_STAGE == 0
// This header is checked in.
#include "upb/reflection/stage0/google/protobuf/descriptor.upb.h"
#elif UPB_BOOTSTRAP_STAGE == 1
#elif defined(UPB_BOOTSTRAP_STAGE) && UPB_BOOTSTRAP_STAGE == 1
// This header is generated at build time by the bootstrapping process.
#include "upb/reflection/stage1/google/protobuf/descriptor.upb.h"
#else
Expand Down
2 changes: 1 addition & 1 deletion upb_generator/plugin_bootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#if defined(UPB_BOOTSTRAP_STAGE) && UPB_BOOTSTRAP_STAGE == 0
// This header is checked in.
#include "upb_generator/stage0/google/protobuf/compiler/plugin.upb.h"
#elif UPB_BOOTSTRAP_STAGE == 1
#elif defined(UPB_BOOTSTRAP_STAGE) && UPB_BOOTSTRAP_STAGE == 1
// This header is generated at build time by the bootstrapping process.
#include "upb_generator/stage1/google/protobuf/compiler/plugin.upb.h"
#else
Expand Down

0 comments on commit 653f511

Please sign in to comment.