Skip to content

Commit b6cba4a

Browse files
committed
Fixed cppcheck-opensource#7784 (Token: can't be both type and variable)
1 parent 55ae961 commit b6cba4a

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

lib/token.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,12 @@ class CPPCHECKLIB Token {
492492
}
493493
void varId(unsigned int id) {
494494
_varId = id;
495-
if (id != 0)
495+
if (id != 0) {
496496
_tokType = eVariable;
497-
else
497+
isStandardType(false);
498+
} else {
498499
update_property_info();
500+
}
499501
}
500502

501503
/**

test/testtoken.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,12 @@ class TestToken : public TestFixture {
830830
// Change back to standard type
831831
tok.str("int");
832832
ASSERT_EQUALS(true, tok.isStandardType());
833+
834+
// token can't be both type and variable
835+
tok.str("abc");
836+
tok.isStandardType(true);
837+
tok.varId(123);
838+
ASSERT_EQUALS(false, tok.isStandardType());
833839
}
834840

835841
void updateProperties() const {

0 commit comments

Comments
 (0)