Changeset c84dd61 for src/Parser
- Timestamp:
- Jun 21, 2023, 2:38:55 AM (17 months ago)
- Branches:
- master
- Children:
- 92355883
- Parents:
- 0b0a285 (diff), 2de175ce (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/Parser
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r0b0a285 rc84dd61 9 9 // Author : Rodolfo G. Esteves 10 10 // Created On : Sat May 16 12:34:05 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Thr Apr 20 11:46:00202313 // Update Count : 1 39311 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 17 14:41:48 2023 13 // Update Count : 1405 14 14 // 15 15 … … 459 459 std::vector<ast::ptr<ast::Expr>> exprs; 460 460 buildList( expr, exprs ); 461 newnode->attributes.push_back( 462 new ast::Attribute( *name, std::move( exprs ) ) ); 461 newnode->attributes.push_back( new ast::Attribute( *name, std::move( exprs ) ) ); 463 462 delete name; 464 463 return newnode; … … 633 632 dst->basictype = src->basictype; 634 633 } else if ( src->basictype != DeclarationNode::NoBasicType ) 635 SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::basicTypeNames[ src->basictype ] + " in type: " ); 634 SemanticError( yylloc, string( "multiple declaration types \"" ) + DeclarationNode::basicTypeNames[ dst->basictype ] + 635 "\" and \"" + DeclarationNode::basicTypeNames[ src->basictype ] + "\"." ); 636 636 637 637 if ( dst->complextype == DeclarationNode::NoComplexType ) { 638 638 dst->complextype = src->complextype; 639 639 } else if ( src->complextype != DeclarationNode::NoComplexType ) 640 SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::complexTypeNames[ src->complextype ] + " in type: " ); 640 SemanticError( yylloc, string( "multiple declaration types \"" ) + DeclarationNode::complexTypeNames[ src->complextype ] + 641 "\" and \"" + DeclarationNode::complexTypeNames[ src->complextype ] + "\"." ); 641 642 642 643 if ( dst->signedness == DeclarationNode::NoSignedness ) { 643 644 dst->signedness = src->signedness; 644 645 } else if ( src->signedness != DeclarationNode::NoSignedness ) 645 SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::signednessNames[ src->signedness ] + " in type: " ); 646 SemanticError( yylloc, string( "conflicting type specifier \"" ) + DeclarationNode::signednessNames[ dst->signedness ] + 647 "\" and \"" + DeclarationNode::signednessNames[ src->signedness ] + "\"." ); 646 648 647 649 if ( dst->length == DeclarationNode::NoLength ) { … … 650 652 dst->length = DeclarationNode::LongLong; 651 653 } else if ( src->length != DeclarationNode::NoLength ) 652 SemanticError( yylloc, src, string( "conflicting type specifier " ) + DeclarationNode::lengthNames[ src->length ] + " in type: " ); 654 SemanticError( yylloc, string( "conflicting type specifier \"" ) + DeclarationNode::lengthNames[ dst->length ] + 655 "\" and \"" + DeclarationNode::lengthNames[ src->length ] + "\"." ); 653 656 } // if 654 657 break; … … 718 721 719 722 DeclarationNode * DeclarationNode::addEnumBase( DeclarationNode * o ) { 720 if ( o && o ->type) {723 if ( o && o->type) { 721 724 type->base= o->type; 722 } 725 } // if 723 726 delete o; 724 727 return this; … … 1003 1006 } 1004 1007 1005 // If a typedef wraps an anonymous declaration, name the inner declaration 1006 // so it has a consistent name acrosstranslation units.1008 // If a typedef wraps an anonymous declaration, name the inner declaration so it has a consistent name across 1009 // translation units. 1007 1010 static void nameTypedefedDecl( 1008 1011 DeclarationNode * innerDecl, … … 1085 1088 } 1086 1089 1087 void buildList( DeclarationNode * firstNode, 1088 std::vector<ast::ptr<ast::Decl>> & outputList ) { 1090 void buildList( DeclarationNode * firstNode, std::vector<ast::ptr<ast::Decl>> & outputList ) { 1089 1091 SemanticErrorException errors; 1090 1092 std::back_insert_iterator<std::vector<ast::ptr<ast::Decl>>> out( outputList ); -
src/Parser/ExpressionNode.cc
r0b0a285 rc84dd61 601 601 ast::Expr * build_cast( const CodeLocation & location, 602 602 DeclarationNode * decl_node, 603 ExpressionNode * expr_node ) { 603 ExpressionNode * expr_node, 604 ast::CastExpr::CastKind kind ) { 604 605 ast::Type * targetType = maybeMoveBuildType( decl_node ); 605 606 if ( dynamic_cast<ast::VoidType *>( targetType ) ) { … … 607 608 return new ast::CastExpr( location, 608 609 maybeMoveBuild( expr_node ), 609 ast::ExplicitCast );610 ast::ExplicitCast, kind ); 610 611 } else { 611 612 return new ast::CastExpr( location, 612 613 maybeMoveBuild( expr_node ), 613 614 targetType, 614 ast::ExplicitCast );615 ast::ExplicitCast, kind ); 615 616 } // if 616 617 } // build_cast -
src/Parser/ExpressionNode.h
r0b0a285 rc84dd61 69 69 ast::DimensionExpr * build_dimensionref( const CodeLocation &, const std::string * name ); 70 70 71 ast::Expr * build_cast( const CodeLocation &, DeclarationNode * decl_node, ExpressionNode * expr_node );71 ast::Expr * build_cast( const CodeLocation &, DeclarationNode * decl_node, ExpressionNode * expr_node, ast::CastExpr::CastKind kind = ast::CastExpr::Default ); 72 72 ast::Expr * build_keyword_cast( const CodeLocation &, ast::AggregateDecl::Aggregate target, ExpressionNode * expr_node ); 73 73 ast::Expr * build_virtual_cast( const CodeLocation &, DeclarationNode * decl_node, ExpressionNode * expr_node ); -
src/Parser/parser.yy
r0b0a285 rc84dd61 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 7 14:32:28202313 // Update Count : 634 112 // Last Modified On : Sat Jun 17 18:53:24 2023 13 // Update Count : 6347 14 14 // 15 15 … … 931 931 { $$ = new ExpressionNode( new ast::VirtualCastExpr( yylloc, maybeMoveBuild( $5 ), maybeMoveBuildType( $3 ) ) ); } 932 932 | '(' RETURN type_no_function ')' cast_expression // CFA 933 { SemanticError( yylloc, "Return cast is currently unimplemented." ); $$ = nullptr; }933 { $$ = new ExpressionNode( build_cast( yylloc, $3, $5, ast::CastExpr::Return ) ); } 934 934 | '(' COERCE type_no_function ')' cast_expression // CFA 935 935 { SemanticError( yylloc, "Coerce cast is currently unimplemented." ); $$ = nullptr; } … … 1040 1040 // FIX ME: computes $1 twice 1041 1041 | logical_OR_expression '?' /* empty */ ':' conditional_expression // GCC, omitted first operand 1042 { $$ = new ExpressionNode( build_cond( yylloc, $1, $1 , $4 ) ); }1042 { $$ = new ExpressionNode( build_cond( yylloc, $1, $1->clone(), $4 ) ); } 1043 1043 ; 1044 1044
Note: See TracChangeset
for help on using the changeset viewer.