diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-06-13 18:36:22 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-06-13 18:36:22 +0300 |
commit | b93d2cb75a0e01876ab600dc3dec6a7f53d4dd8c (patch) | |
tree | 41e9d0c0e8aaf072714b6f2a67b642be3fc10138 /src/parsers | |
parent | 23c4fc020718cfbc43bc83d3b5ce88ab5bdab111 (diff) | |
download | paranucker-b93d2cb75a0e01876ab600dc3dec6a7f53d4dd8c.tar.gz paranucker-b93d2cb75a0e01876ab600dc3dec6a7f53d4dd8c.tar.bz2 paranucker-b93d2cb75a0e01876ab600dc3dec6a7f53d4dd8c.tar.xz paranucker-b93d2cb75a0e01876ab600dc3dec6a7f53d4dd8c.zip |
Fix different crash issues.
Diffstat (limited to 'src/parsers')
-rw-r--r-- | src/parsers/decl/function_decl.cpp | 3 | ||||
-rw-r--r-- | src/parsers/generic.cpp | 45 | ||||
-rw-r--r-- | src/parsers/type/union_type.cpp | 3 |
3 files changed, 27 insertions, 24 deletions
diff --git a/src/parsers/decl/function_decl.cpp b/src/parsers/decl/function_decl.cpp index 76f9f00..08304de 100644 --- a/src/parsers/decl/function_decl.cpp +++ b/src/parsers/decl/function_decl.cpp @@ -50,10 +50,9 @@ void parseFunctionDeclNode(FunctionDeclNode *node) return; fillDeclAttributes(node); - node->functionType = static_cast<FunctionTypeNode*>(createParseNode( + node->functionType = static_cast<TypeNode*>(createParseNode( node, TREE_TYPE(node->gccNode), - FUNCTION_TYPE, "function type")); node->result = static_cast<ResultDeclNode*>(createParseNode( node, diff --git a/src/parsers/generic.cpp b/src/parsers/generic.cpp index 6b621b3..b2743a4 100644 --- a/src/parsers/generic.cpp +++ b/src/parsers/generic.cpp @@ -85,19 +85,6 @@ Node *createParseNode(Node *parent, node->parent = parent; node->gccNode = gccNode; node->parseChilds = parseChilds; - if (parent) - { - node->indent = parent->indent + 1; - if (tag.empty()) - node->tag = parent->tag; - else - node->tag = tag; - parent->childs.push_back(node); - } - else - { - node->tag = tag; - } if (wantType != ERROR_MARK && TREE_CODE(node->gccNode) != wantType) @@ -107,21 +94,34 @@ Node *createParseNode(Node *parent, Log::dump(node, "Wrong node type. Want %s but get %s", get_tree_code_name(wantType), - node->nodeTypeName.c_str()); + get_tree_code_name(TREE_CODE(node->gccNode))); } else { Log::dump(node, "Wrong node type. Want %s but get %s - %s", get_tree_code_name(wantType), - node->nodeTypeName.c_str(), + get_tree_code_name(TREE_CODE(node->gccNode)), tag.c_str()); } - if (!parent) - delete node; + delete node; return nullptr; } + if (parent) + { + node->indent = parent->indent + 1; + if (tag.empty()) + node->tag = parent->tag; + else + node->tag = tag; + parent->childs.push_back(node); + } + else + { + node->tag = tag; + } + switch (TREE_CODE(node->gccNode)) { #undef handleNodeType @@ -200,10 +200,13 @@ void fillLocation(Node *node) } location_t loc = DECL_SOURCE_LOCATION(node->gccNode); - node->location = loc; - node->file = LOCATION_FILE(loc); - node->line = LOCATION_LINE(loc); - node->column = LOCATION_COLUMN(loc); + if (loc) + { + node->location = loc; + node->file = LOCATION_FILE(loc); + node->line = LOCATION_LINE(loc); + node->column = LOCATION_COLUMN(loc); + } } } diff --git a/src/parsers/type/union_type.cpp b/src/parsers/type/union_type.cpp index c429f66..93e5d96 100644 --- a/src/parsers/type/union_type.cpp +++ b/src/parsers/type/union_type.cpp @@ -44,7 +44,8 @@ void parseUnionTypeNode(UnionTypeNode *node) node->methods = createParseNode( node, TYPE_METHODS(node->gccNode), - "type methods"); + "type methods", + false); } } |