Skip to content

Commit a18d104

Browse files
committed
Revert "remove type signatures from AST in generic selections"
This reverts commit 33841b4. Revert "fix #13561" This reverts commit 0c4564a.
1 parent 33841b4 commit a18d104

File tree

3 files changed

+1
-33
lines changed

3 files changed

+1
-33
lines changed

lib/tokenlist.cpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -828,13 +828,6 @@ static void compileTerm(Token *&tok, AST_state& state)
828828
}
829829
if (Token::Match(tok, "%name% %assign%"))
830830
tok = tok->next();
831-
if (Token::simpleMatch(tok, "*")) {
832-
Token *tok2 = tok->next();
833-
while (Token::simpleMatch(tok2, "*"))
834-
tok2 = tok2->next();
835-
if (Token::simpleMatch(tok2, ":"))
836-
tok = tok2;
837-
}
838831
}
839832
} else if (tok->str() == "{") {
840833
const Token *prev = tok->previous();
@@ -1804,7 +1797,6 @@ void TokenList::createAst() const
18041797
throw InternalError(tok, "Syntax Error: Infinite loop when creating AST.", InternalError::AST);
18051798
tok = nextTok;
18061799
}
1807-
removeGenericTypes();
18081800
}
18091801

18101802
namespace {
@@ -2246,25 +2238,3 @@ void TokenList::setLang(Standards::Language lang, bool force)
22462238

22472239
mLang = lang;
22482240
}
2249-
2250-
void TokenList::removeGenericTypes() const
2251-
{
2252-
for (Token *tok = mTokensFrontBack.front; tok != mTokensFrontBack.back; tok = tok->next()) {
2253-
if (!Token::simpleMatch(tok, "_Generic"))
2254-
continue;
2255-
tok = tok->next();
2256-
Token *link = tok->link();
2257-
tok = tok->astOperand2();
2258-
2259-
while (tok) {
2260-
if (Token::simpleMatch(tok->astOperand2(), ":")) {
2261-
Token *tok2 = tok->astOperand2()->astOperand2();
2262-
tok2->astParent(nullptr);
2263-
tok->astOperand2(tok2);
2264-
}
2265-
tok = tok->astOperand1();
2266-
}
2267-
2268-
tok = link;
2269-
}
2270-
}

lib/tokenlist.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,6 @@ class CPPCHECKLIB TokenList {
206206

207207
bool createTokensInternal(std::istream &code, const std::string& file0);
208208

209-
void removeGenericTypes() const;
210-
211209
/** Token list */
212210
TokensFrontBack mTokensFrontBack;
213211

test/testtokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8394,7 +8394,7 @@ class TestTokenizer : public TestFixture {
83948394

83958395
void genericInIf() { // #13561
83968396
const char code[] = " if (_Generic(s, char * : 1, const float * : 2, volatile int * : 3, default : 0)) {}";
8397-
const char ast[] = "(( if (( _Generic (, (, (, (, s 1) 2) 3) 0)))";
8397+
const char ast[] = "(( if (( _Generic (, (, (, (, s (: char 1)) (: float 2)) (: int 3)) (: default 0))))";
83988398
ASSERT_EQUALS(ast, testAst(code, AstStyle::Z3));
83998399
}
84008400
};

0 commit comments

Comments
 (0)