Merge pull request #8859 from tamird/warnings

Disallow missing field initializers
pull/8862/head
Matt Fowles Kulukundis 3 years ago committed by GitHub
commit 51405b6b92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      BUILD
  2. 6
      src/google/protobuf/arena_impl.h
  3. 2
      src/google/protobuf/compiler/cpp/cpp_helpers.cc
  4. 10
      src/google/protobuf/compiler/cpp/cpp_helpers.h
  5. 5
      src/google/protobuf/io/tokenizer_unittest.cc

@ -48,6 +48,7 @@ COPTS = select({
"//conditions:default": [ "//conditions:default": [
"-DHAVE_PTHREAD", "-DHAVE_PTHREAD",
"-DHAVE_ZLIB", "-DHAVE_ZLIB",
"-Wmissing-field-initializers",
"-Woverloaded-virtual", "-Woverloaded-virtual",
"-Wno-sign-compare", "-Wno-sign-compare",
], ],

@ -206,13 +206,15 @@ class PROTOBUF_EXPORT SerialArena {
// Blocks are variable length malloc-ed objects. The following structure // Blocks are variable length malloc-ed objects. The following structure
// describes the common header for all blocks. // describes the common header for all blocks.
struct Block { struct Block {
Block(Block* next, size_t size) : next(next), size(size), start(nullptr) {}
char* Pointer(size_t n) { char* Pointer(size_t n) {
GOOGLE_DCHECK(n <= size); GOOGLE_DCHECK(n <= size);
return reinterpret_cast<char*>(this) + n; return reinterpret_cast<char*>(this) + n;
} }
Block* next; Block* const next;
size_t size; const size_t size;
CleanupNode* start; CleanupNode* start;
// data follows // data follows
}; };

@ -1130,7 +1130,7 @@ bool IsImplicitWeakField(const FieldDescriptor* field, const Options& options,
MessageAnalysis MessageSCCAnalyzer::GetSCCAnalysis(const SCC* scc) { MessageAnalysis MessageSCCAnalyzer::GetSCCAnalysis(const SCC* scc) {
if (analysis_cache_.count(scc)) return analysis_cache_[scc]; if (analysis_cache_.count(scc)) return analysis_cache_[scc];
MessageAnalysis result{}; MessageAnalysis result;
if (UsingImplicitWeakFields(scc->GetFile(), options_)) { if (UsingImplicitWeakFields(scc->GetFile(), options_)) {
result.contains_weak = true; result.contains_weak = true;
} }

@ -545,11 +545,11 @@ inline static bool ShouldIgnoreRequiredFieldCheck(const FieldDescriptor* field,
} }
struct MessageAnalysis { struct MessageAnalysis {
bool is_recursive; bool is_recursive = false;
bool contains_cord; bool contains_cord = false;
bool contains_extension; bool contains_extension = false;
bool contains_required; bool contains_required = false;
bool contains_weak; // Implicit weak as well. bool contains_weak = false; // Implicit weak as well.
}; };
// This class is used in FileGenerator, to ensure linear instead of // This class is used in FileGenerator, to ensure linear instead of

@ -325,10 +325,7 @@ TEST_1D(TokenizerTest, FloatSuffix, kBlockSizes) {
// last token in "output" must have type TYPE_END. // last token in "output" must have type TYPE_END.
struct MultiTokenCase { struct MultiTokenCase {
std::string input; std::string input;
Tokenizer::Token output[10]; // The compiler wants a constant array std::vector<Tokenizer::Token> output;
// size for initialization to work. There
// is no reason this can't be increased if
// needed.
}; };
inline std::ostream& operator<<(std::ostream& out, inline std::ostream& operator<<(std::ostream& out,

Loading…
Cancel
Save