Skip to content

Commit a409730

Browse files
committed
Fix #14539
1 parent d84ccf4 commit a409730

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

lib/checkother.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2024,7 +2024,7 @@ void CheckOther::checkConstPointer()
20242024
// continue;
20252025
if (!isConstPointerVariable(p, *mSettings))
20262026
continue;
2027-
if (p->typeStartToken() && p->typeStartToken()->isSimplifiedTypedef() && !(Token::simpleMatch(p->typeEndToken(), "*") && !p->typeEndToken()->isSimplifiedTypedef()))
2027+
if (p->typeStartToken() && p->typeStartToken()->isSimplifiedTypedefOrUsing() && !(Token::simpleMatch(p->typeEndToken(), "*") && !p->typeEndToken()->isSimplifiedTypedefOrUsing()))
20282028
continue;
20292029
constVariableError(p, p->isArgument() ? p->scope()->function : nullptr);
20302030
}

lib/token.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,17 @@ class CPPCHECKLIB Token {
655655
setFlag(fIsSimplifiedTypedef, b);
656656
}
657657

658+
bool isSimplifiedUsing() const {
659+
return getFlag(fIsSimplifiedUsing);
660+
}
661+
void isSimplifiedUsing(bool b) {
662+
setFlag(fIsSimplifiedUsing, b);
663+
}
664+
665+
bool isSimplifiedTypedefOrUsing() const {
666+
return isSimplifiedTypedef() || isSimplifiedUsing();
667+
}
668+
658669
bool isIncompleteConstant() const {
659670
return getFlag(fIsIncompleteConstant);
660671
}
@@ -1509,6 +1520,7 @@ class CPPCHECKLIB Token {
15091520
fIsInitComma = (1ULL << 43), // Is this comma located inside some {..}. i.e: {1,2,3,4}
15101521
fIsInitBracket = (1ULL << 44), // Is this bracket used as a part of variable initialization i.e: int a{5}, b(2);
15111522
fIsAnonymous = (1ULL << 45), // Is this a token added for an unnamed member
1523+
fIsSimplifiedUsing = (1ULL << 46),
15121524
};
15131525

15141526
enum : std::uint8_t {

lib/tokenize.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2998,6 +2998,9 @@ bool Tokenizer::simplifyUsing()
29982998
if (!usingEnd)
29992999
continue;
30003000

3001+
for (Token *typeTok = start; typeTok != usingEnd; typeTok = typeTok->next())
3002+
typeTok->isSimplifiedUsing(true);
3003+
30013004
// Move struct defined in using out of using.
30023005
// using T = struct t { }; => struct t { }; using T = struct t;
30033006
// fixme: this doesn't handle attributes

0 commit comments

Comments
 (0)