Merge branch 'master' of http://github.com/danmar/cppcheck
This commit is contained in:
commit
1eccc2937c
8
Makefile
8
Makefile
|
@ -1,7 +1,7 @@
|
||||||
# This file is generated by tools/dmake, do not edit.
|
# This file is generated by tools/dmake, do not edit.
|
||||||
|
|
||||||
ifndef CXXFLAGS
|
ifndef CXXFLAGS
|
||||||
CXXFLAGS=-Wall -Wextra -Wshadow -pedantic -Wno-long-long -Wfloat-equal -Wcast-qual -Wsign-conversion -Wconversion -g
|
CXXFLAGS=-Wall -Wextra -Wshadow -pedantic -Wno-long-long -Wfloat-equal -Wcast-qual -Wsign-conversion -g
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifndef CXX
|
ifndef CXX
|
||||||
|
@ -103,8 +103,8 @@ cppcheck: $(LIBOBJ) $(CLIOBJ) $(EXTOBJ)
|
||||||
|
|
||||||
all: cppcheck testrunner
|
all: cppcheck testrunner
|
||||||
|
|
||||||
testrunner: $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o
|
testrunner: $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o cli/filelister.o cli/filelister_unix.o
|
||||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) -lpcre cli/threadexecutor.o cli/cmdlineparser.o cli/cppcheckexecutor.o $(LDFLAGS)
|
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o testrunner $(TESTOBJ) $(LIBOBJ) $(EXTOBJ) -lpcre cli/threadexecutor.o cli/cmdlineparser.o cli/filelister.o cli/filelister_unix.o $(LDFLAGS)
|
||||||
|
|
||||||
test: all
|
test: all
|
||||||
./testrunner
|
./testrunner
|
||||||
|
@ -113,7 +113,7 @@ check: all
|
||||||
./testrunner -g -q
|
./testrunner -g -q
|
||||||
|
|
||||||
dmake: tools/dmake.cpp
|
dmake: tools/dmake.cpp
|
||||||
$(CXX) -o dmake tools/dmake.cpp lib/filelister*.cpp
|
$(CXX) -o dmake tools/dmake.cpp cli/filelister*.cpp lib/path.cpp -Ilib
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f lib/*.o cli/*.o test/*.o externals/tinyxml/*.o testrunner cppcheck cppcheck.1
|
rm -f lib/*.o cli/*.o test/*.o externals/tinyxml/*.o testrunner cppcheck cppcheck.1
|
||||||
|
|
|
@ -908,7 +908,7 @@ void CheckClass::checkReturnPtrThis(const Scope *scope, const Function *func, co
|
||||||
// check if it is a member function
|
// check if it is a member function
|
||||||
for (it = scope->functionList.begin(); it != scope->functionList.end(); ++it)
|
for (it = scope->functionList.begin(); it != scope->functionList.end(); ++it)
|
||||||
{
|
{
|
||||||
// check for a regular function with the same name and a bofy
|
// check for a regular function with the same name and a body
|
||||||
if (it->type == Function::eFunction && it->hasBody &&
|
if (it->type == Function::eFunction && it->hasBody &&
|
||||||
it->token->str() == tok->next()->str())
|
it->token->str() == tok->next()->str())
|
||||||
{
|
{
|
||||||
|
@ -918,7 +918,16 @@ void CheckClass::checkReturnPtrThis(const Scope *scope, const Function *func, co
|
||||||
{
|
{
|
||||||
// make sure it's not a const function
|
// make sure it's not a const function
|
||||||
if (it->arg->link()->next()->str() != "const")
|
if (it->arg->link()->next()->str() != "const")
|
||||||
|
{
|
||||||
|
/** @todo make sure argument types match */
|
||||||
|
// make sure it's not the same function
|
||||||
|
if (&*it != func)
|
||||||
checkReturnPtrThis(scope, &*it, it->arg->link()->next(), it->arg->link()->next()->link());
|
checkReturnPtrThis(scope, &*it, it->arg->link()->next(), it->arg->link()->next()->link());
|
||||||
|
|
||||||
|
// just bail for now
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,7 @@ private:
|
||||||
TEST_CASE(operatorEqRetRefThis3); // ticket #1405
|
TEST_CASE(operatorEqRetRefThis3); // ticket #1405
|
||||||
TEST_CASE(operatorEqRetRefThis4); // ticket #1451
|
TEST_CASE(operatorEqRetRefThis4); // ticket #1451
|
||||||
TEST_CASE(operatorEqRetRefThis5); // ticket #1550
|
TEST_CASE(operatorEqRetRefThis5); // ticket #1550
|
||||||
|
TEST_CASE(operatorEqRetRefThis6); // ticket #2479
|
||||||
TEST_CASE(operatorEqToSelf1); // single class
|
TEST_CASE(operatorEqToSelf1); // single class
|
||||||
TEST_CASE(operatorEqToSelf2); // nested class
|
TEST_CASE(operatorEqToSelf2); // nested class
|
||||||
TEST_CASE(operatorEqToSelf3); // multiple inheritance
|
TEST_CASE(operatorEqToSelf3); // multiple inheritance
|
||||||
|
@ -475,6 +476,23 @@ private:
|
||||||
ASSERT_EQUALS("[test.cpp:5]: (style) 'operator=' should return reference to self\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:5]: (style) 'operator=' should return reference to self\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void operatorEqRetRefThis6() // ticket #2478 (segmentation fault)
|
||||||
|
{
|
||||||
|
checkOpertorEqRetRefThis(
|
||||||
|
"class UString {\n"
|
||||||
|
"public:\n"
|
||||||
|
" UString& assign( const char* c_str );\n"
|
||||||
|
" UString& operator=( const UString& s );\n"
|
||||||
|
"};\n"
|
||||||
|
"UString& UString::assign( const char* c_str ) {\n"
|
||||||
|
" std::string tmp( c_str );\n"
|
||||||
|
" return assign( tmp );\n"
|
||||||
|
"}\n"
|
||||||
|
"UString& UString::operator=( const UString& s ) {\n"
|
||||||
|
" return assign( s );\n"
|
||||||
|
"}\n");
|
||||||
|
}
|
||||||
|
|
||||||
// Check that operator Equal checks for assignment to self
|
// Check that operator Equal checks for assignment to self
|
||||||
void checkOpertorEqToSelf(const char code[])
|
void checkOpertorEqToSelf(const char code[])
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,8 @@ public:
|
||||||
,si(NULL, NULL, NULL)
|
,si(NULL, NULL, NULL)
|
||||||
,vartok(NULL)
|
,vartok(NULL)
|
||||||
,typetok(NULL)
|
,typetok(NULL)
|
||||||
|
,t(NULL)
|
||||||
|
,found(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -237,7 +237,7 @@ int main(int argc, char **argv)
|
||||||
fout << "check:\tall\n";
|
fout << "check:\tall\n";
|
||||||
fout << "\t./testrunner -g -q\n\n";
|
fout << "\t./testrunner -g -q\n\n";
|
||||||
fout << "dmake:\ttools/dmake.cpp\n";
|
fout << "dmake:\ttools/dmake.cpp\n";
|
||||||
fout << "\t$(CXX) -o dmake tools/dmake.cpp lib/filelister*.cpp\n\n";
|
fout << "\t$(CXX) -o dmake tools/dmake.cpp cli/filelister*.cpp lib/path.cpp -Ilib\n\n";
|
||||||
fout << "clean:\n";
|
fout << "clean:\n";
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
fout << "\tdel lib\*.o\n\tdel cli\*.o\n\tdel test\*.o\n\tdel *.exe\n";
|
fout << "\tdel lib\*.o\n\tdel cli\*.o\n\tdel test\*.o\n\tdel *.exe\n";
|
||||||
|
|
Loading…
Reference in New Issue