Virtual destructor : minor fix to avoid false positives when more modifiers are used
This commit is contained in:
parent
02f3196b24
commit
ddd20a2977
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* c++check - c/c++ syntax checking
|
* c++check - c/c++ syntax checking
|
||||||
* Copyright (C) 2007 Daniel Marjamäki
|
* Copyright (C) 2007 Daniel Marjamäki
|
||||||
*
|
*
|
||||||
|
@ -684,13 +684,13 @@ void CheckClass::CheckOperatorEq1()
|
||||||
|
|
||||||
void CheckClass::virtualDestructor()
|
void CheckClass::virtualDestructor()
|
||||||
{
|
{
|
||||||
const char pattern_classdecl[] = "class %var% : %var%";
|
const char pattern_classdecl[] = "class %var% : %var%";
|
||||||
|
|
||||||
const TOKEN *derived = _tokenizer->tokens();
|
const TOKEN *derived = _tokenizer->tokens();
|
||||||
while ((derived = TOKEN::findmatch(derived, pattern_classdecl)) != NULL)
|
while ((derived = TOKEN::findmatch(derived, pattern_classdecl)) != NULL)
|
||||||
{
|
{
|
||||||
// Iterate through each base class...
|
// Iterate through each base class...
|
||||||
derived = derived->tokAt(3);
|
derived = derived->tokAt(3);
|
||||||
while ( TOKEN::Match(derived, "%var%") )
|
while ( TOKEN::Match(derived, "%var%") )
|
||||||
{
|
{
|
||||||
bool isPublic = TOKEN::Match(derived, "public");
|
bool isPublic = TOKEN::Match(derived, "public");
|
||||||
|
@ -718,6 +718,9 @@ void CheckClass::virtualDestructor()
|
||||||
while (TOKEN::Match(base, "::"))
|
while (TOKEN::Match(base, "::"))
|
||||||
base = TOKEN::findmatch(base->next(), "%any% ~ %var1% (", baseName);
|
base = TOKEN::findmatch(base->next(), "%any% ~ %var1% (", baseName);
|
||||||
|
|
||||||
|
while (TOKEN::Match(base, "%var%") && !TOKEN::Match(base, "virtual"))
|
||||||
|
base = base->previous();
|
||||||
|
|
||||||
// Check that there is a destructor..
|
// Check that there is a destructor..
|
||||||
if ( ! base )
|
if ( ! base )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue