- Timestamp:
- Nov 23, 2024, 8:28:37 PM (14 months ago)
- Branches:
- master
- Children:
- 956b389
- Parents:
- b006c51e (diff), de7b7a5 (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
- Files:
-
- 29 edited
-
AST/Expr.hpp (modified) (2 diffs)
-
AST/Pass.hpp (modified) (1 diff)
-
CodeGen/CodeGenerator.cpp (modified) (1 diff)
-
Concurrency/Actors.cpp (modified) (2 diffs)
-
Concurrency/Corun.cpp (modified) (1 diff)
-
Concurrency/Keywords.cpp (modified) (3 diffs)
-
Concurrency/Waituntil.cpp (modified) (1 diff)
-
ControlStruct/ExceptDecl.cpp (modified) (1 diff)
-
GenPoly/Box.cpp (modified) (3 diffs)
-
GenPoly/InstantiateGeneric.cpp (modified) (2 diffs)
-
GenPoly/Lvalue.cpp (modified) (7 diffs)
-
GenPoly/Specialize.cpp (modified) (1 diff)
-
InitTweak/FixInit.cpp (modified) (4 diffs)
-
InitTweak/GenInit.cpp (modified) (2 diffs)
-
Parser/ExpressionNode.cpp (modified) (1 diff)
-
Parser/ExpressionNode.hpp (modified) (1 diff)
-
Parser/parser.yy (modified) (8 diffs)
-
ResolvExpr/CandidateFinder.cpp (modified) (1 diff)
-
ResolvExpr/ConversionCost.cpp (modified) (2 diffs)
-
ResolvExpr/Resolver.cpp (modified) (2 diffs)
-
Tuples/TupleExpansion.cpp (modified) (2 diffs)
-
Validate/Autogen.cpp (modified) (1 diff)
-
Validate/CompoundLiteral.cpp (modified) (1 diff)
-
Validate/HoistStruct.cpp (modified) (1 diff)
-
Validate/HoistTypeDecls.cpp (modified) (1 diff)
-
Validate/ImplementEnumFunc.cpp (modified) (1 diff)
-
Validate/LinkInstanceTypes.cpp (modified) (1 diff)
-
Validate/ReplaceTypedef.cpp (modified) (1 diff)
-
Virtual/VirtualDtor.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Expr.hpp
rb006c51e r10a9479d 330 330 enum GeneratedFlag { ExplicitCast, GeneratedCast }; 331 331 332 /// Even within the basic cast expression there are variants: 333 /// CCast - C-Style Cast: A backwards compatable cast from C. 334 /// CoerceCast - Coercion Cast: Change the type without changing the value. 335 /// ReturnCast - Ascription Cast: Requires the given expression result type. 336 enum CastKind { CCast, CoerceCast, ReturnCast }; 337 332 338 /// A type cast, e.g. `(int)e` 333 339 class CastExpr final : public Expr { … … 336 342 GeneratedFlag isGenerated; 337 343 338 enum CastKind { 339 Default, // C 340 Coerce, // reinterpret cast 341 Return // overload selection 342 }; 343 344 CastKind kind = Default; 344 CastKind kind = CCast; 345 345 346 346 CastExpr( const CodeLocation & loc, const Expr * a, const Type * to, 347 GeneratedFlag g = GeneratedCast, CastKind kind = Default ) : Expr( loc, to ), arg( a ), isGenerated( g ), kind( kind ) {}347 GeneratedFlag g = GeneratedCast, CastKind kind = CCast ) : Expr( loc, to ), arg( a ), isGenerated( g ), kind( kind ) {} 348 348 /// Cast-to-void 349 CastExpr( const CodeLocation & loc, const Expr * a, GeneratedFlag g = GeneratedCast, CastKind kind = Default );349 CastExpr( const CodeLocation & loc, const Expr * a, GeneratedFlag g = GeneratedCast, CastKind kind = CCast ); 350 350 351 351 /// Wrap a cast expression around an existing expression (always generated) -
src/AST/Pass.hpp
rb006c51e r10a9479d 327 327 /// The Pass template handles what *before* and *after* means automatically 328 328 template< template<class...> class container_t = std::list > 329 struct WithStmtsToAdd {329 struct WithStmtsToAddX { 330 330 container_t< ptr<Stmt> > stmtsToAddBefore; 331 331 container_t< ptr<Stmt> > stmtsToAddAfter; 332 332 }; 333 334 struct WithStmtsToAdd : public WithStmtsToAddX<> {}; 333 335 334 336 /// Used if visitor requires added declarations before or after the current node. 335 337 /// The Pass template handles what *before* and *after* means automatically 336 338 template< template<class...> class container_t = std::list > 337 struct WithDeclsToAdd {339 struct WithDeclsToAddX { 338 340 container_t< ptr<Decl> > declsToAddBefore; 339 341 container_t< ptr<Decl> > declsToAddAfter; 340 342 }; 343 344 struct WithDeclsToAdd : public WithDeclsToAddX<> {}; 341 345 342 346 /// Use if visitation should stop at certain levels -
src/CodeGen/CodeGenerator.cpp
rb006c51e r10a9479d 680 680 extension( expr ); 681 681 output << "("; 682 if ( expr->result->isVoid() ) { 683 output << "(void)"; 684 } else { 685 output << "("; 682 switch ( expr->kind ) { 683 case ast::CCast: 684 if ( expr->result->isVoid() ) { 685 output << "(void)"; 686 } else { 687 output << "("; 688 output << genType( expr->result, "", options ); 689 output << ")"; 690 } 691 break; 692 case ast::CoerceCast: 693 assertf( ast::CoerceCast != expr->kind, "Coercion cast is not implemented." ); 694 // And likely shouldn't reach code generation when it is implemented. 695 break; 696 case ast::ReturnCast: 697 // This should be invisible in the resulting C code. 698 // Can we insert a check here? 699 //assert( ResolvExpr::typesCompatable(???) ); 700 if ( options.genC ) break; 701 output << "(return "; 686 702 output << genType( expr->result, "", options ); 687 703 output << ")"; 704 break; 688 705 } 689 706 expr->arg->accept( *visitor ); -
src/Concurrency/Actors.cpp
rb006c51e r10a9479d 194 194 // collects data needed for next pass that does the circular defn resolution 195 195 // for message send operators (via table above) 196 struct GenFuncsCreateTables : public ast::WithDeclsToAdd <>{196 struct GenFuncsCreateTables : public ast::WithDeclsToAdd { 197 197 unordered_set<const StructDecl *> & actorStructDecls; 198 198 unordered_set<const StructDecl *> & messageStructDecls; … … 451 451 // separate pass is needed since this pass resolves circular defn issues 452 452 // generates the forward declarations of the send operator for actor routines 453 struct FwdDeclOperator : public ast::WithDeclsToAdd <>{453 struct FwdDeclOperator : public ast::WithDeclsToAdd { 454 454 unordered_set<const StructDecl *> & actorStructDecls; 455 455 unordered_set<const StructDecl *> & messageStructDecls; -
src/Concurrency/Corun.cpp
rb006c51e r10a9479d 25 25 namespace Concurrency { 26 26 27 struct CorunKeyword : public WithDeclsToAdd <>, public WithStmtsToAdd<>{27 struct CorunKeyword : public WithDeclsToAdd, public WithStmtsToAdd { 28 28 UniqueName CorunFnNamer = "__CFA_corun_lambda_"s; 29 29 UniqueName CoforFnNamer = "__CFA_cofor_lambda_"s; -
src/Concurrency/Keywords.cpp
rb006c51e r10a9479d 117 117 118 118 // -------------------------------------------------------------------------- 119 struct ConcurrentSueKeyword : public ast::WithDeclsToAdd <>{119 struct ConcurrentSueKeyword : public ast::WithDeclsToAdd { 120 120 ConcurrentSueKeyword( 121 121 std::string&& type_name, std::string&& field_name, … … 639 639 // -------------------------------------------------------------------------- 640 640 struct SuspendKeyword final : 641 public ast::WithStmtsToAdd <>, public ast::WithGuards {641 public ast::WithStmtsToAdd, public ast::WithGuards { 642 642 SuspendKeyword() = default; 643 643 virtual ~SuspendKeyword() = default; … … 860 860 861 861 // -------------------------------------------------------------------------- 862 struct MutexKeyword final : public ast::WithDeclsToAdd <>{862 struct MutexKeyword final : public ast::WithDeclsToAdd { 863 863 const ast::FunctionDecl * postvisit( const ast::FunctionDecl * decl ); 864 864 void postvisit( const ast::StructDecl * decl ); -
src/Concurrency/Waituntil.cpp
rb006c51e r10a9479d 1398 1398 // To add the predicates at global scope we need to do it in a second pass 1399 1399 // Predicates are added after "struct select_node { ... };" 1400 class AddPredicateDecls final : public WithDeclsToAdd <>{1400 class AddPredicateDecls final : public WithDeclsToAdd { 1401 1401 vector<FunctionDecl *> & satFns; 1402 1402 const StructDecl * selectNodeDecl = nullptr; -
src/ControlStruct/ExceptDecl.cpp
rb006c51e r10a9479d 401 401 } 402 402 403 struct ExceptDeclCore : public ast::WithDeclsToAdd <>{403 struct ExceptDeclCore : public ast::WithDeclsToAdd { 404 404 ast::StructDecl const * transformExcept( ast::StructDecl const * decl ); 405 405 ast::ObjectDecl const * transformVTable( -
src/GenPoly/Box.cpp
rb006c51e r10a9479d 55 55 /// Adds layout-generation functions to polymorphic types. 56 56 struct LayoutFunctionBuilder final : 57 public ast::WithDeclsToAdd <>,57 public ast::WithDeclsToAdd, 58 58 public ast::WithShortCircuiting, 59 59 public ast::WithVisitorRef<LayoutFunctionBuilder> { … … 344 344 public ast::WithGuards, 345 345 public ast::WithShortCircuiting, 346 public ast::WithStmtsToAdd <>,346 public ast::WithStmtsToAdd, 347 347 public ast::WithVisitorRef<CallAdapter> { 348 348 CallAdapter(); … … 1575 1575 struct PolyGenericCalculator final : 1576 1576 public ast::WithConstTypeSubstitution, 1577 public ast::WithDeclsToAdd <>,1577 public ast::WithDeclsToAdd, 1578 1578 public ast::WithGuards, 1579 public ast::WithStmtsToAdd <>,1579 public ast::WithStmtsToAdd, 1580 1580 public ast::WithVisitorRef<PolyGenericCalculator> { 1581 1581 PolyGenericCalculator(); -
src/GenPoly/InstantiateGeneric.cpp
rb006c51e r10a9479d 277 277 public ast::WithVisitorRef<FixDtypeStatic>, 278 278 public ast::WithShortCircuiting, 279 public ast::WithStmtsToAdd <>{279 public ast::WithStmtsToAdd { 280 280 ast::ApplicationExpr const * previsit( ast::ApplicationExpr const * expr ); 281 281 void previsit( ast::AddressExpr const * expr ); … … 421 421 public ast::WithCodeLocation, 422 422 public ast::WithConstTypeSubstitution, 423 public ast::WithDeclsToAdd <>,423 public ast::WithDeclsToAdd, 424 424 public ast::WithGuards, 425 425 public ast::WithVisitorRef<GenericInstantiator> -
src/GenPoly/Lvalue.cpp
rb006c51e r10a9479d 85 85 struct ReferenceConversions final : 86 86 public ast::WithConstTranslationUnit, 87 public ast::WithGuards, public ast::WithStmtsToAdd <>{87 public ast::WithGuards, public ast::WithStmtsToAdd { 88 88 ast::Expr const * postvisit( ast::CastExpr const * expr ); 89 89 ast::Expr const * postvisit( ast::AddressExpr const * expr ); … … 316 316 Warning::RvalueToReferenceConversion, toCString( expr->arg ) ); 317 317 318 // allowing conversion in the rvalue to const ref case 319 // use the referenced-to type to create temp variables 320 ast::Type const * targetType = dstType; 321 for (int i = 0; i < diff; ++i) targetType = (strict_dynamic_cast<ast::ReferenceType const *>(targetType))->base; 322 318 323 static UniqueName tmpNamer( "__ref_tmp_" ); 319 324 ast::ObjectDecl * tmp = new ast::ObjectDecl( expr->arg->location, 320 325 tmpNamer.newName(), 321 ast::deepCopy( expr->arg->result ), 326 // ast::deepCopy( expr->arg->result ), 327 ast::deepCopy (targetType), 322 328 new ast::SingleInit( expr->arg->location, expr->arg ) ); 323 329 PRINT( std::cerr << "make tmp: " << tmp << std::endl; ) … … 359 365 ret = new ast::AddressExpr( ret->location, ret ); 360 366 } 361 if ( expr->arg->get_lvalue() && 362 !ResolvExpr::typesCompatible( 363 srcType, 364 strict_dynamic_cast<ast::ReferenceType const *>( dstType )->base ) ) { 365 // Must keep cast if cast-to type is different from the actual type. 367 // Must keep cast if types are different. 368 if ( !ResolvExpr::typesCompatible( 369 srcType, 370 strict_dynamic_cast<ast::ReferenceType const *>( dstType )->base ) ) { 366 371 return ast::mutate_field( expr, &ast::CastExpr::arg, ret ); 367 372 } … … 377 382 } 378 383 // Must keep cast if types are different. 379 if ( !ResolvExpr::typesCompatible IgnoreQualifiers(384 if ( !ResolvExpr::typesCompatible( 380 385 dstType->stripReferences(), 381 386 srcType->stripReferences() ) ) { … … 390 395 } else { 391 396 assert( 0 == diff ); 392 // Remove useless generated casts.393 if ( expr->isGenerated == ast::GeneratedFlag::GeneratedCast &&394 ResolvExpr::typesCompatible(397 // Must keep cast if types are different. (Or it is explicit.) 398 if ( ast::ExplicitCast == expr->isGenerated || 399 !ResolvExpr::typesCompatible( 395 400 expr->result, 396 401 expr->arg->result ) ) { 397 PRINT( 398 std::cerr << "types are compatible, removing cast: " << expr << '\n'; 399 std::cerr << "-- " << expr->result << '\n'; 400 std::cerr << "-- " << expr->arg->result << std::endl; 401 ) 402 auto argAsEnum = expr->arg.as<ast::EnumInstType>(); 403 auto resultAsEnum = expr->result.as<ast::EnumInstType>(); 404 if (argAsEnum && resultAsEnum) { 405 if (argAsEnum->base->name != resultAsEnum->base->name) { 406 return expr; 407 } 408 } 409 return ast::mutate_field( expr->arg.get(), 410 &ast::Expr::env, expr->env.get() ); 411 } 412 return expr; 402 return expr; 403 } 404 PRINT( 405 std::cerr << "types are compatible, removing cast: " << expr << '\n'; 406 std::cerr << "-- " << expr->result << '\n'; 407 std::cerr << "-- " << expr->arg->result << std::endl; 408 ) 409 return ast::mutate_field( expr->arg.get(), 410 &ast::Expr::env, expr->env.get() ); 413 411 } 414 412 } … … 505 503 } 506 504 505 /// Recursively move an address expression underneath casts. Casts are not 506 /// lvalue expressions in C but are sometimes considered as such in Cforall, 507 /// (passes like InstantiateGeneric can add them.) - &(int) => (int*)& 508 ast::Expr const * moveAddressUnderCast( ast::AddressExpr const * expr ) { 509 if ( !dynamic_cast<ast::CastExpr const *>( expr->arg.get() ) ) { 510 return expr; 511 } 512 auto mutExpr = ast::mutate( expr ); 513 auto mutCast = strict_dynamic_cast<ast::CastExpr *>( 514 ast::mutate( mutExpr->arg.release() ) ); 515 mutExpr->arg = mutCast->arg; 516 mutCast->arg = moveAddressUnderCast( mutExpr ); 517 mutCast->result = new ast::PointerType( mutCast->result ); 518 return mutCast; 519 } 520 507 521 ast::Expr const * CollapseAddressDeref::postvisit( 508 522 ast::AddressExpr const * expr ) { … … 516 530 return ret; 517 531 } 518 } else if ( auto cast = dynamic_cast<ast::CastExpr const *>( arg ) ) { 519 // Need to move cast to pointer type out a level since address of 520 // pointer is not valid C code (can be introduced in prior passes, 521 // e.g., InstantiateGeneric) 522 if ( ast::getPointerBase( cast->result ) ) { 523 auto mutExpr = ast::mutate( expr ); 524 auto mutCast = strict_dynamic_cast<ast::CastExpr *>( 525 ast::mutate( mutExpr->arg.release() ) ); 526 mutExpr->arg = mutCast->arg; 527 mutCast->arg = mutExpr; 528 mutCast->result = new ast::PointerType( mutCast->result ); 529 return mutCast; 530 } 532 } else { 533 return moveAddressUnderCast( expr ); 531 534 } 532 535 return expr; -
src/GenPoly/Specialize.cpp
rb006c51e r10a9479d 30 30 struct SpecializeCore final : 31 31 public ast::WithConstTypeSubstitution, 32 public ast::WithDeclsToAdd <>,32 public ast::WithDeclsToAdd, 33 33 public ast::WithVisitorRef<SpecializeCore> { 34 34 std::string paramPrefix = "_p"; -
src/InitTweak/FixInit.cpp
rb006c51e r10a9479d 105 105 /// generate/resolve copy construction expressions for each, and generate/resolve destructors for both 106 106 /// arguments and return value temporaries 107 struct ResolveCopyCtors final : public ast::WithGuards, public ast::WithStmtsToAdd <>, public ast::WithSymbolTable, public ast::WithShortCircuiting, public ast::WithVisitorRef<ResolveCopyCtors>, public ast::WithConstTranslationUnit {107 struct ResolveCopyCtors final : public ast::WithGuards, public ast::WithStmtsToAdd, public ast::WithSymbolTable, public ast::WithShortCircuiting, public ast::WithVisitorRef<ResolveCopyCtors>, public ast::WithConstTranslationUnit { 108 108 const ast::Expr * postvisit( const ast::ImplicitCopyCtorExpr * impCpCtorExpr ); 109 109 const ast::StmtExpr * previsit( const ast::StmtExpr * stmtExpr ); … … 177 177 /// insert destructor calls at the appropriate places. must happen before CtorInit nodes are removed 178 178 /// (currently by FixInit) 179 struct InsertDtors final : public ObjDeclCollector, public ast::WithStmtsToAdd <>{179 struct InsertDtors final : public ObjDeclCollector, public ast::WithStmtsToAdd { 180 180 InsertDtors( ast::Pass<LabelFinder> & finder ) : finder( finder ), labelVars( finder.core.vars ) {} 181 181 … … 194 194 195 195 /// expand each object declaration to use its constructor after it is declared. 196 struct FixInit : public ast::WithStmtsToAdd <>{196 struct FixInit : public ast::WithStmtsToAdd { 197 197 static void fixInitializers( ast::TranslationUnit &translationUnit ); 198 198 … … 230 230 231 231 /// expands ConstructorExpr nodes into comma expressions, using a temporary for the first argument 232 struct FixCtorExprs final : public ast::WithDeclsToAdd <>, public ast::WithSymbolTable, public ast::WithShortCircuiting, public ast::WithConstTranslationUnit {232 struct FixCtorExprs final : public ast::WithDeclsToAdd, public ast::WithSymbolTable, public ast::WithShortCircuiting, public ast::WithConstTranslationUnit { 233 233 const ast::Expr * postvisit( const ast::ConstructorExpr * ctorExpr ); 234 234 }; -
src/InitTweak/GenInit.cpp
rb006c51e r10a9479d 46 46 // Outer pass finds declarations, for their type could wrap a type that needs hoisting 47 47 struct HoistArrayDimension_NoResolve final : 48 public ast::WithDeclsToAdd <>, public ast::WithShortCircuiting,48 public ast::WithDeclsToAdd, public ast::WithShortCircuiting, 49 49 public ast::WithGuards, public ast::WithConstTranslationUnit, 50 50 public ast::WithVisitorRef<HoistArrayDimension_NoResolve>, … … 205 205 206 206 struct ReturnFixer final : 207 public ast::WithStmtsToAdd <>, ast::WithGuards, ast::WithShortCircuiting {207 public ast::WithStmtsToAdd, ast::WithGuards, ast::WithShortCircuiting { 208 208 void previsit( const ast::FunctionDecl * decl ); 209 209 const ast::ReturnStmt * previsit( const ast::ReturnStmt * stmt ); -
src/Parser/ExpressionNode.cpp
rb006c51e r10a9479d 652 652 DeclarationNode * decl_node, 653 653 ExpressionNode * expr_node, 654 ast::Cast Expr::CastKind kind ) {654 ast::CastKind kind ) { 655 655 ast::Type * targetType = maybeMoveBuildType( decl_node ); 656 656 if ( dynamic_cast<ast::VoidType *>( targetType ) ) { -
src/Parser/ExpressionNode.hpp
rb006c51e r10a9479d 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, ast::Cast Expr::CastKind kind = ast::CastExpr::Default );71 ast::Expr * build_cast( const CodeLocation &, DeclarationNode * decl_node, ExpressionNode * expr_node, ast::CastKind kind = ast::CCast ); 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
rb006c51e r10a9479d 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Oct 13 12:18:15202413 // Update Count : 6 84512 // Last Modified On : Fri Nov 15 15:01:33 2024 13 // Update Count : 6915 14 14 // 15 15 … … 24 24 // the grammar. 25 25 26 // The root language for this grammar is ANSI99/11 C. All of ANSI99/11 is parsed, except for: 27 // 28 // designation with '=' (use ':' instead) 29 // 30 // This incompatibility is discussed in detail before the "designation" grammar rule. Most of the syntactic extensions 31 // from ANSI90 to ANSI11 C are marked with the comment "C99/C11". 26 // The root language for this grammar is ANSI99/11 C. All of ANSI99/11 is parsed. Most of the syntactic extensions from 27 // ANSI90 to ANSI11 C are marked with the comment "C99/C11". 32 28 33 29 // This grammar also has two levels of extensions. The first extensions cover most of the GCC C extensions. All of the … … 983 979 { $$ = new ExpressionNode( new ast::VirtualCastExpr( yylloc, maybeMoveBuild( $5 ), maybeMoveBuildType( $3 ) ) ); } 984 980 | '(' RETURN type_no_function ')' cast_expression // CFA 985 { $$ = new ExpressionNode( build_cast( yylloc, $3, $5, ast:: CastExpr::Return) ); }981 { $$ = new ExpressionNode( build_cast( yylloc, $3, $5, ast::ReturnCast ) ); } 986 982 | '(' COERCE type_no_function ')' cast_expression // CFA 987 983 { SemanticError( yylloc, "Coerce cast is currently unimplemented." ); $$ = nullptr; } … … 1170 1166 // comma_expression in cfa_identifier_parameter_array and cfa_abstract_array 1171 1167 '[' ',' ']' 1172 { $$ = new ExpressionNode( build_tuple( yylloc, nullptr ) ); } 1168 // { $$ = new ExpressionNode( build_tuple( yylloc, nullptr ) ); } 1169 { SemanticError( yylloc, "Empty tuple is meaningless." ); $$ = nullptr; } 1173 1170 | '[' assignment_expression ',' ']' 1174 1171 { $$ = new ExpressionNode( build_tuple( yylloc, $2 ) ); } … … 1224 1221 | DIRECTIVE 1225 1222 { $$ = new StatementNode( build_directive( yylloc, $1 ) ); } 1223 // | attribute ';' 1224 // { $$ = new StatementNode( $1 ); } 1226 1225 ; 1227 1226 … … 2057 2056 | cfa_abstract_tuple identifier_or_type_name asm_name_opt 2058 2057 { $$ = $1->addName( $2 )->addAsmName( $3 ); } 2059 | type_qualifier_list cfa_abstract_tuple identifier_or_type_name asm_name_opt 2060 { $$ = $2->addQualifiers( $1 )->addName( $3 )->addAsmName( $4 ); } 2058 | multi_array_dimension cfa_abstract_tuple identifier_or_type_name asm_name_opt 2059 { $$ = $2->addNewArray( $1 )->addName( $3 )->addAsmName( $4 ); } 2060 | multi_array_dimension type_qualifier_list cfa_abstract_tuple identifier_or_type_name asm_name_opt 2061 { $$ = $3->addNewArray( $1 )->addQualifiers( $2 )->addName( $4 )->addAsmName( $5 ); } 2061 2062 2062 2063 // [ int s, int t ]; // declare s and t … … 4223 4224 cfa_identifier_parameter_ptr 4224 4225 | cfa_identifier_parameter_array 4226 | type_qualifier_list cfa_identifier_parameter_array 4227 { $$ = $2->addQualifiers( $1 ); } 4225 4228 ; 4226 4229 … … 4246 4249 '[' ']' type_specifier_nobody 4247 4250 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 4251 | '[' ']' cfa_abstract_tuple 4252 { $$ = $3->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 4248 4253 | cfa_array_parameter_1st_dimension type_specifier_nobody 4254 { $$ = $2->addNewArray( $1 ); } 4255 | cfa_array_parameter_1st_dimension cfa_abstract_tuple 4249 4256 { $$ = $2->addNewArray( $1 ); } 4250 4257 | '[' ']' multi_array_dimension type_specifier_nobody 4251 4258 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 4259 | '[' ']' multi_array_dimension cfa_abstract_tuple 4260 { $$ = $4->addNewArray( $3 )->addNewArray( DeclarationNode::newArray( nullptr, nullptr, false ) ); } 4252 4261 | cfa_array_parameter_1st_dimension multi_array_dimension type_specifier_nobody 4253 4262 { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); } 4263 | cfa_array_parameter_1st_dimension multi_array_dimension cfa_abstract_tuple 4264 { $$ = $3->addNewArray( $2 )->addNewArray( $1 ); } 4254 4265 | multi_array_dimension type_specifier_nobody 4266 { $$ = $2->addNewArray( $1 ); } 4267 | multi_array_dimension cfa_abstract_tuple 4255 4268 { $$ = $2->addNewArray( $1 ); } 4256 4269 -
src/ResolvExpr/CandidateFinder.cpp
rb006c51e r10a9479d 1220 1220 finder.allowVoid = true; 1221 1221 } 1222 if ( castExpr->kind == ast::CastExpr::Return) {1222 if ( ast::ReturnCast == castExpr->kind ) { 1223 1223 finder.strictMode = true; 1224 1224 finder.find( castExpr->arg, ResolveMode::withAdjustment() ); -
src/ResolvExpr/ConversionCost.cpp
rb006c51e r10a9479d 250 250 newSrc = new ast::BasicType( ast::BasicKind::UnsignedInt ); 251 251 } 252 if (dstAsRef->base->is_const() ) { 253 auto cvtCost = conversionCost(newSrc, dstAsRef->base, srcIsLvalue, symtab, env) ; 254 if (cvtCost == Cost::zero) { // exact match, may use a lvalue src 255 if ( srcIsLvalue ) { 256 if ( src->qualifiers == dstAsRef->base->qualifiers ) { 257 return Cost::reference; 258 } else if ( src->qualifiers < dstAsRef->base->qualifiers ) { 259 return Cost::safe; 260 } else { 261 return Cost::unsafe; 262 } 263 } 264 else { 265 return Cost::reference; 266 } 267 } 268 else { // not exact match, conversion is needed so lvalueness of src does not matter 269 return cvtCost + Cost::reference; 270 } 271 } 252 272 if ( typesCompatibleIgnoreQualifiers( newSrc, dstAsRef->base, env ) ) { 253 273 if ( srcIsLvalue ) { … … 259 279 return Cost::unsafe; 260 280 } 261 } else if ( dstAsRef->base->is_const() ) { 262 return Cost::safe; 263 } else { 281 } else { // rvalue-to-NC-ref conversion 264 282 return Cost::unsafe; 265 283 } -
src/ResolvExpr/Resolver.cpp
rb006c51e r10a9479d 201 201 && typesCompatible( castExpr->arg->result, castExpr->result ) 202 202 ) { 203 auto argAsEnum = castExpr->arg.as<ast::EnumInstType>(); 204 auto resultAsEnum = castExpr->result.as<ast::EnumInstType>(); 205 if (argAsEnum && resultAsEnum) { 206 if (argAsEnum->base->name != resultAsEnum->base->name) { 207 std::cerr << "Enum Cast: " << argAsEnum->base->name << " to " << resultAsEnum->base->name << std::endl; 208 return castExpr; 209 } 203 ast::EnumInstType const * arg, * result; 204 if ( ( result = castExpr->result.as<ast::EnumInstType>() ) && 205 ( arg = castExpr->arg.as<ast::EnumInstType>() ) && 206 arg->base->name != result->base->name) { 207 return castExpr; 210 208 } 211 209 // generated cast is the same type as its argument, remove it after keeping env … … 377 375 : public ast::WithSymbolTable, public ast::WithGuards, 378 376 public ast::WithVisitorRef<Resolver>, public ast::WithShortCircuiting, 379 public ast::WithStmtsToAdd <>{377 public ast::WithStmtsToAdd { 380 378 381 379 ast::ptr< ast::Type > functionReturn = nullptr; -
src/Tuples/TupleExpansion.cpp
rb006c51e r10a9479d 28 28 }; 29 29 30 struct UniqueExprExpander final : public ast::WithDeclsToAdd <>{30 struct UniqueExprExpander final : public ast::WithDeclsToAdd { 31 31 const ast::Expr * postvisit( const ast::UniqueExpr * unqExpr ); 32 32 // Not a vector, because they may not be adding in increasing order. … … 37 37 struct TupleMainExpander final : 38 38 public ast::WithCodeLocation, 39 public ast::WithDeclsToAdd <>,39 public ast::WithDeclsToAdd, 40 40 public ast::WithGuards, 41 41 public ast::WithVisitorRef<TupleMainExpander> { -
src/Validate/Autogen.cpp
rb006c51e r10a9479d 50 50 // -------------------------------------------------------------------------- 51 51 struct AutogenerateRoutines final : 52 public ast::WithDeclsToAdd <>,52 public ast::WithDeclsToAdd, 53 53 public ast::WithShortCircuiting { 54 54 void previsit( const ast::EnumDecl * enumDecl ); -
src/Validate/CompoundLiteral.cpp
rb006c51e r10a9479d 27 27 28 28 struct CompoundLiteral final : 29 public ast::WithDeclsToAdd <>{29 public ast::WithDeclsToAdd { 30 30 ast::Storage::Classes storageClasses; 31 31 -
src/Validate/HoistStruct.cpp
rb006c51e r10a9479d 68 68 */ 69 69 struct HoistStructCore final : 70 public ast::WithDeclsToAdd <>, public ast::WithGuards {70 public ast::WithDeclsToAdd, public ast::WithGuards { 71 71 ast::StructDecl const * previsit( ast::StructDecl const * decl ); 72 72 ast::StructDecl const * postvisit( ast::StructDecl const * decl ); -
src/Validate/HoistTypeDecls.cpp
rb006c51e r10a9479d 22 22 namespace { 23 23 24 struct HoistTypeDecls final : public ast::WithDeclsToAdd <>{24 struct HoistTypeDecls final : public ast::WithDeclsToAdd { 25 25 void previsit( ast::SizeofExpr const * ); 26 26 void previsit( ast::AlignofExpr const * ); -
src/Validate/ImplementEnumFunc.cpp
rb006c51e r10a9479d 472 472 473 473 struct ImplementEnumFunc final : 474 public ast::WithDeclsToAdd <>, public ast::WithShortCircuiting {474 public ast::WithDeclsToAdd, public ast::WithShortCircuiting { 475 475 void previsit(const ast::EnumDecl* enumDecl); 476 476 void previsit(const ast::FunctionDecl* functionDecl); -
src/Validate/LinkInstanceTypes.cpp
rb006c51e r10a9479d 27 27 struct LinkTypesCore : public WithNoIdSymbolTable, 28 28 public ast::WithCodeLocation, 29 public ast::WithDeclsToAdd <>,29 public ast::WithDeclsToAdd, 30 30 public ast::WithGuards, 31 31 public ast::WithShortCircuiting, -
src/Validate/ReplaceTypedef.cpp
rb006c51e r10a9479d 28 28 struct ReplaceTypedefCore final : 29 29 public ast::WithCodeLocation, 30 public ast::WithDeclsToAdd <>,30 public ast::WithDeclsToAdd, 31 31 public ast::WithGuards, 32 32 public ast::WithShortCircuiting, -
src/Virtual/VirtualDtor.cpp
rb006c51e r10a9479d 119 119 // collects data needed for next pass that does the circular defn resolution 120 120 // for dtor setters and delete fns (via table above) 121 struct GenFuncsCreateTables : public ast::WithDeclsToAdd <>{121 struct GenFuncsCreateTables : public ast::WithDeclsToAdd { 122 122 unordered_map<const StructDecl *, CtorDtor> & structDecls; 123 123 CtorDtorTable & torDecls; … … 351 351 // separate pass is needed since __CFA_set_dtor needs to be defined after 352 352 // the last dtor defn which is found in prior pass 353 struct GenSetDtor : public ast::WithDeclsToAdd <>{353 struct GenSetDtor : public ast::WithDeclsToAdd { 354 354 unordered_map<const StructDecl *, CtorDtor> & structDecls; // set of decls that inherit from virt dtor 355 355 CtorDtorTable & torDecls;
Note:
See TracChangeset
for help on using the changeset viewer.