Skip to content

Commit 0adf09c

Browse files
committed
ClangImport; Fixed output for anonymous enum
1 parent 79a8f21 commit 0adf09c

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

lib/clangimport.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,9 @@ const ::Type * clangimport::AstNode::addTypeTokens(TokenList *tokenList, const s
497497
return addTypeTokens(tokenList, str.substr(0, str.find("\':\'") + 1), scope);
498498
}
499499

500+
if (str.compare(0, 16, "'enum (anonymous") == 0)
501+
return nullptr;
502+
500503
std::string type;
501504
if (str.find(" (") != std::string::npos) {
502505
if (str.find("<") != std::string::npos)

test/testclangimport.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class TestClangImport: public TestFixture {
7474
TEST_CASE(enumDecl1);
7575
TEST_CASE(enumDecl2);
7676
TEST_CASE(enumDecl3);
77+
TEST_CASE(enumDecl4);
7778
TEST_CASE(forStmt);
7879
TEST_CASE(funcdecl1);
7980
TEST_CASE(funcdecl2);
@@ -690,6 +691,16 @@ class TestClangImport: public TestFixture {
690691
ASSERT_EQUALS("enum __syntax_option { _S_polynomial , _S_syntax_last }", parse(clang));
691692
}
692693

694+
void enumDecl4() {
695+
const char clang[] = "|-EnumDecl 0xace1f8 <e1.cpp:3:1, col:51> col:1\n"
696+
"| |-EnumConstantDecl 0xace2c8 <col:7> col:7 A '(anonymous enum at e1.cpp:3:1)'\n"
697+
"| |-EnumConstantDecl 0xace318 <col:16> col:16 B '(anonymous enum at e1.cpp:3:1)'\n"
698+
"| `-EnumConstantDecl 0xace3b8 <col:46> col:46 referenced C '(anonymous enum at e1.cpp:3:1)'\n"
699+
"`-VarDecl 0xace470 <col:1, col:66> col:53 x 'enum (anonymous enum at e1.cpp:3:1)':'(anonymous enum at e1.cpp:3:1)' cinit\n"
700+
" `-DeclRefExpr 0xace520 <col:66> '(anonymous enum at e1.cpp:3:1)' EnumConstant 0xace3b8 'C' '(anonymous enum at e1.cpp:3:1)'";
701+
ASSERT_EQUALS("enum { A , B , C } x@1 = C ;", parse(clang));
702+
}
703+
693704
void forStmt() {
694705
const char clang[] = "`-FunctionDecl 0x2f93ae0 <1.c:1:1, col:56> col:5 main 'int ()'\n"
695706
" `-CompoundStmt 0x2f93dc0 <col:12, col:56>\n"

0 commit comments

Comments
 (0)