diff --git a/CheckOther.cpp b/CheckOther.cpp index 61c903d36..232db1d13 100644 --- a/CheckOther.cpp +++ b/CheckOther.cpp @@ -1,4 +1,4 @@ -/* +/* * c++check - c/c++ syntax checking * Copyright (C) 2007 Daniel Marjamäki * @@ -34,16 +34,16 @@ //--------------------------------------------------------------------------- // Warning on C-Style casts.. p = (kalle *)foo; //--------------------------------------------------------------------------- - -CheckOther::CheckOther( Tokenizer *tokenizer ) -{ - _tokenizer = tokenizer; -} - -CheckOther::~CheckOther() -{ - -} + +CheckOther::CheckOther( Tokenizer *tokenizer ) +{ + _tokenizer = tokenizer; +} + +CheckOther::~CheckOther() +{ + +} void CheckOther::WarningOldStylePointerCast() { diff --git a/CheckOther.h b/CheckOther.h index e08578057..86a2cc9f3 100644 --- a/CheckOther.h +++ b/CheckOther.h @@ -1,4 +1,4 @@ -/* +/* * c++check - c/c++ syntax checking * Copyright (C) 2007 Daniel Marjamäki * @@ -22,14 +22,14 @@ #ifndef CheckOtherH #define CheckOtherH //--------------------------------------------------------------------------- - -#include "tokenize.h" -class CheckOther -{ -public: - CheckOther( Tokenizer *tokenizer ); - ~CheckOther(); +#include "tokenize.h" + +class CheckOther +{ +public: + CheckOther( Tokenizer *tokenizer ); + ~CheckOther(); // Casting void WarningOldStylePointerCast(); @@ -71,12 +71,12 @@ public: void CheckCharVariable(); // Incomplete statement. A statement that only contains a constant or variable - void CheckIncompleteStatement(); -private: - void CheckVariableScope_LookupVar( const TOKEN *tok1, const char varname[] ); - + void CheckIncompleteStatement(); +private: + void CheckVariableScope_LookupVar( const TOKEN *tok1, const char varname[] ); + Tokenizer *_tokenizer; -}; +}; //--------------------------------------------------------------------------- #endif diff --git a/testconstructors.cpp b/testconstructors.cpp index 665c66e6b..8688d8a72 100644 --- a/testconstructors.cpp +++ b/testconstructors.cpp @@ -1,4 +1,4 @@ -/* +/* * c++check - c/c++ syntax checking * Copyright (C) 2007 Daniel Marjamäki * @@ -36,7 +36,7 @@ private: void check( const char code[] ) { // Tokenize.. - Tokenizer tokenizer; + Tokenizer tokenizer; tokenizer.getFiles()->push_back( "test.cpp" ); std::istringstream istr(code); tokenizer.TokenizeCode( istr ); @@ -64,6 +64,7 @@ private: TEST_CASE( initvar_operator_eq ); // BUG 2190376 TEST_CASE( initvar_same_classname ); // BUG 2208157 TEST_CASE( initvar_chained_assign ); // BUG 2270433 + // TODO TEST_CASE( initvar_2constructors ); // BUG 2270353 } @@ -226,6 +227,40 @@ private: } + void initvar_2constructors() + { + check( "class c\n" + "{\n" + " c();\n" + " c(bool b);" + "\n" + " void InitInt();\n" + "\n" + " int m_iMyInt;\n" + " int m_bMyBool;\n" + "}\n" + "\n" + "c::c()\n" + "{\n" + " m_bMyBool = false;\n" + " InitInt();" + "}\n" + "\n" + "c::c(bool b)\n" + "{\n" + " m_bMyBool = b;\n" + " InitInt();\n" + "}\n" + "\n" + "void c::InitInt()\n" + "{\n" + " m_iMyInt = 0;\n" + "}\n" ); + + std::string err( errout.str() ); + ASSERT_EQUALS( std::string(""), err ); + } + }; REGISTER_TEST( TestConstructors )