diff options
Diffstat (limited to 'c_compiler/src/c_parser.y')
-rw-r--r-- | c_compiler/src/c_parser.y | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/c_compiler/src/c_parser.y b/c_compiler/src/c_parser.y index 5c464cd..c2086fd 100644 --- a/c_compiler/src/c_parser.y +++ b/c_compiler/src/c_parser.y @@ -202,7 +202,12 @@ TypeQualifier: DirectDeclarator: T_IDENTIFIER { $$ = new Declaration(*$1); delete $1; } | T_LRB Declarator T_RRB { $$ = $2; } -| DirectDeclarator T_LSB ConditionalExpression T_RSB { $$ = new ArrayDeclaration($1->getId(), $1->getInitializer(), $3->constantFold()); } + | DirectDeclarator T_LSB ConditionalExpression T_RSB + { + $$ = new ArrayDeclaration($1->getId(), $1->getInitializer(), $3->constantFold()); + TypePtr tmp_ptr = std::make_shared<Array>($3->constantFold()); + $$->setType(tmp_ptr); + } | DirectDeclarator T_LSB T_RSB { $$ = $1; } | DirectDeclarator T_LRB T_RRB { $$ = $1; $$->setExternDeclaration(true); } | DirectDeclarator T_LRB ParameterList T_RRB { $1->linkDeclaration($3); $$ = $1; $$->setExternDeclaration(true); } |