diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp index 08dc2779a..2d196f168 100644 --- a/lib/clangimport.cpp +++ b/lib/clangimport.cpp @@ -558,8 +558,9 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList) if (nodeType == CallExpr) return createTokensCall(tokenList); if (nodeType == CaseStmt) { - addtoken(tokenList, "case"); - children[0]->createTokens(tokenList); + Token *caseToken = addtoken(tokenList, "case"); + Token *exprToken = children[0]->createTokens(tokenList); + caseToken->astOperand1(exprToken); addtoken(tokenList, ":"); children.back()->createTokens(tokenList); return nullptr; @@ -604,7 +605,7 @@ Token *clangimport::AstNode::createTokens(TokenList *tokenList) return nullptr; } if (nodeType == ConstantExpr) - return children[0]->createTokens(tokenList); + return children.back()->createTokens(tokenList); if (nodeType == ContinueStmt) return addtoken(tokenList, "continue"); if (nodeType == CStyleCastExpr) { diff --git a/test/cli/test-clang-import.py b/test/cli/test-clang-import.py index b3970f21f..6bb5dadc0 100644 --- a/test/cli/test-clang-import.py +++ b/test/cli/test-clang-import.py @@ -89,7 +89,7 @@ def test_ast_calculations(): def test_ast_control_flow(): check_ast('void foo(int x) { if (x > 5){} }') check_ast('int dostuff() { for (int x = 0; x < 10; x++); }') - todo_check_ast('void foo(int x) { switch (x) {case 1: break; } }') + check_ast('void foo(int x) { switch (x) {case 1: break; } }')