authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-01-29 02:38:12-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-01-29 02:38:12-07:00
log2e39d9881a68b7e4a4e765e06e898c2deeb30703
tree013a9d1bbb6642cd265a169ce1adb13aacf95bef
parenta94ad9e89c8e9f1ca11ca194f690460725676b3b

parseh fix crash


1 files changed, 5 insertions(+), 3 deletions(-)

src/parseh.cpp+5-3
...@@ -109,6 +109,7 @@ static AstNode *create_var_decl_node(Context *c, const char *var_name, AstNode *...@@ -109,6 +109,7 @@ static AstNode *create_var_decl_node(Context *c, const char *var_name, AstNode *
109}109}
110110
111static AstNode *create_prefix_node(Context *c, PrefixOp op, AstNode *child_node) {111static AstNode *create_prefix_node(Context *c, PrefixOp op, AstNode *child_node) {
112 assert(child_node);
112 AstNode *node = create_node(c, NodeTypePrefixOpExpr);113 AstNode *node = create_node(c, NodeTypePrefixOpExpr);
113 node->data.prefix_op_expr.prefix_op = op;114 node->data.prefix_op_expr.prefix_op = op;
114 node->data.prefix_op_expr.primary_expr = child_node;115 node->data.prefix_op_expr.primary_expr = child_node;
...@@ -195,9 +196,7 @@ static AstNode *convert_to_c_void(Context *c, AstNode *type_node) {...@@ -195,9 +196,7 @@ static AstNode *convert_to_c_void(Context *c, AstNode *type_node) {
195}196}
196197
197static AstNode *pointer_to_type(Context *c, AstNode *type_node, bool is_const) {198static AstNode *pointer_to_type(Context *c, AstNode *type_node, bool is_const) {
198 if (!type_node) {199 assert(type_node);
199 return nullptr;
200 }
201 PrefixOp op = is_const ? PrefixOpConstAddressOf : PrefixOpAddressOf;200 PrefixOp op = is_const ? PrefixOpConstAddressOf : PrefixOpAddressOf;
202 AstNode *child_node = create_prefix_node(c, op, convert_to_c_void(c, type_node));201 AstNode *child_node = create_prefix_node(c, op, convert_to_c_void(c, type_node));
203 return create_prefix_node(c, PrefixOpMaybe, child_node);202 return create_prefix_node(c, PrefixOpMaybe, child_node);
...@@ -278,6 +277,9 @@ static AstNode *make_type_node(Context *c, const Type *ty, const Decl *decl,...@@ -278,6 +277,9 @@ static AstNode *make_type_node(Context *c, const Type *ty, const Decl *decl,
278 const PointerType *pointer_ty = static_cast<const PointerType*>(ty);277 const PointerType *pointer_ty = static_cast<const PointerType*>(ty);
279 QualType child_qt = pointer_ty->getPointeeType();278 QualType child_qt = pointer_ty->getPointeeType();
280 AstNode *type_node = make_qual_type_node(c, child_qt, decl);279 AstNode *type_node = make_qual_type_node(c, child_qt, decl);
280 if (!type_node) {
281 return nullptr;
282 }
281 if (child_qt.getTypePtr()->getTypeClass() == Type::Paren) {283 if (child_qt.getTypePtr()->getTypeClass() == Type::Paren) {
282 const ParenType *paren_type = static_cast<const ParenType *>(child_qt.getTypePtr());284 const ParenType *paren_type = static_cast<const ParenType *>(child_qt.getTypePtr());
283 if (paren_type->getInnerType()->getTypeClass() == Type::FunctionProto) {285 if (paren_type->getInnerType()->getTypeClass() == Type::FunctionProto) {