From fbbddb1b67ab30b1c73a9ff1ae41ee5e344c0197 Mon Sep 17 00:00:00 2001 From: Ivan Komissarov Date: Sat, 4 Apr 2020 14:43:49 +0200 Subject: clang-tidy: Fix 'cppcoreguidelines-pro-type-member-init' warnings Also, fix undefined behavior when setting and reading different field of a union (Lexer, Token) - according to the C++ Standard, it is not allowed to use a union to zero members of a struct. Treat these warnings as errors now. Change-Id: I0f6d071217ef55e2c75c51138fcff47048eca62f Reviewed-by: Christian Kandeler --- src/plugins/scanner/cpp/Token.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/plugins/scanner/cpp/Token.h') diff --git a/src/plugins/scanner/cpp/Token.h b/src/plugins/scanner/cpp/Token.h index 846aa5a12..a042c1087 100644 --- a/src/plugins/scanner/cpp/Token.h +++ b/src/plugins/scanner/cpp/Token.h @@ -295,9 +295,6 @@ enum Kind { class CPLUSPLUS_EXPORT Token { public: - Token(); - ~Token(); - inline bool is(unsigned k) const { return f.kind == k; } inline bool isNot(unsigned k) const { return f.kind != k; } #ifndef CPLUSPLUS_NO_PARSER @@ -348,15 +345,12 @@ public: unsigned pad : 3; unsigned length : 16; }; - union { - unsigned flags; - Flags f; - }; + Flags f{}; unsigned offset = 0; union { - void *ptr; + void *ptr = nullptr; #ifndef CPLUSPLUS_NO_PARSER const Literal *literal; const NumericLiteral *number; -- cgit v1.2.1