Skip to content

Commit 77aea97

Browse files
authored
Fix #13100 (ValueType::TypeScope set wrong) (danmar#6894)
1 parent 266c553 commit 77aea97

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

lib/symboldatabase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7568,7 +7568,7 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to
75687568
else if (tok->previous() && tok->previous()->function() && tok->previous()->function()->isConstructor()) {
75697569
ValueType valuetype;
75707570
valuetype.type = ValueType::RECORD;
7571-
valuetype.typeScope = tok->previous()->function()->token->scope();
7571+
valuetype.typeScope = tok->previous()->function()->tokenDef->scope();
75727572
setValueType(tok, valuetype);
75737573
}
75747574

lib/token.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include <cstdio>
3737
#include <cstring>
3838
#include <functional>
39+
#include <iostream>
3940
#include <iterator>
4041
#include <map>
4142
#include <set>
@@ -1177,6 +1178,11 @@ void Token::createMutualLinks(Token *begin, Token *end)
11771178
end->link(begin);
11781179
}
11791180

1181+
void Token::printOut() const
1182+
{
1183+
printOut(std::cout, "");
1184+
}
1185+
11801186
void Token::printOut(std::ostream& out, const char *title) const
11811187
{
11821188
if (title && title[0])

lib/token.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -968,16 +968,19 @@ class CPPCHECKLIB Token {
968968
}
969969

970970
/**
971-
* For debugging purposes, prints token and all tokens
972-
* followed by it.
971+
* For debugging purposes, prints token and all tokens followed by it.
972+
*/
973+
void printOut() const;
974+
975+
/**
976+
* For debugging purposes, prints token and all tokens followed by it.
973977
* @param title Title for the printout or use default parameter or 0
974978
* for no title.
975979
*/
976980
void printOut(std::ostream& out, const char *title = nullptr) const;
977981

978982
/**
979-
* For debugging purposes, prints token and all tokens
980-
* followed by it.
983+
* For debugging purposes, prints token and all tokens followed by it.
981984
* @param title Title for the printout or use default parameter or 0
982985
* for no title.
983986
* @param fileNames Prints out file name instead of file index.

test/testsymboldatabase.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9207,6 +9207,9 @@ class TestSymbolDatabase : public TestFixture {
92079207
ASSERT_EQUALS("signed int &&", typeOf("std::move(5);", "( 5 )"));
92089208
ASSERT_EQUALS("signed int", typeOf("using F = int(int*); F* f; f(ptr);", "( ptr")); // #9792
92099209

9210+
// calling constructor..
9211+
ASSERT_EQUALS("s", typeOf("struct s { s(int); }; s::s(int){} void foo() { throw s(1); } ", "( 1 )")); // #13100
9212+
92109213
// struct member..
92119214
ASSERT_EQUALS("signed int", typeOf("struct AB { int a; int b; } ab; x = ab.a;", "."));
92129215
ASSERT_EQUALS("signed int", typeOf("struct AB { int a; int b; } *ab; x = ab[1].a;", "."));

0 commit comments

Comments
 (0)