Changeset fdd3786
- Timestamp:
- Nov 20, 2017, 12:12:43 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 50abab9
- Parents:
- 0cf5b79 (diff), c0b23644 (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:
-
- 2 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r0cf5b79 rfdd3786 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Sep 23 18:16:48201713 // Update Count : 10 2412 // Last Modified On : Mon Nov 20 09:21:52 2017 13 // Update Count : 1031 14 14 // 15 15 … … 509 509 510 510 DeclarationNode * DeclarationNode::addQualifiers( DeclarationNode * q ) { 511 if ( ! q ) { delete q; return this; } 511 if ( ! q ) { delete q; return this; } // empty qualifier 512 512 513 513 checkSpecifiers( q ); 514 514 copySpecifiers( q ); 515 515 516 if ( ! q->type ) { 517 delete q; 518 return this; 519 } // if 516 if ( ! q->type ) { delete q; return this; } 520 517 521 518 if ( ! type ) { 522 type = q->type; // reuse thisstructure519 type = q->type; // reuse structure 523 520 q->type = nullptr; 524 521 delete q; … … 526 523 } // if 527 524 528 if ( q->type->forall ) { 529 if ( type->forall ) { 530 type->forall->appendList( q->type->forall ); 525 if ( q->type->forall ) { // forall qualifier ? 526 if ( type->forall ) { // polymorphic routine ? 527 type->forall->appendList( q->type->forall ); // augment forall qualifier 531 528 } else { 532 if ( type->kind == TypeData::Aggregate ) { 533 type->aggregate.params = q->type->forall; 534 // change implicit typedef from TYPEDEFname to TYPEGENname 535 typedefTable.changeKind( *type->aggregate.name, TypedefTable::TG ); 536 } else { 537 type->forall = q->type->forall; 529 if ( type->kind == TypeData::Aggregate ) { // struct/union ? 530 if ( type->aggregate.params ) { // polymorphic ? 531 type->aggregate.params->appendList( q->type->forall ); // augment forall qualifier 532 } else { // not polymorphic 533 type->aggregate.params = q->type->forall; // make polymorphic type 534 // change implicit typedef from TYPEDEFname to TYPEGENname 535 typedefTable.changeKind( *type->aggregate.name, TypedefTable::TG ); 536 } // if 537 } else { // not polymorphic 538 type->forall = q->type->forall; // make polymorphic routine 538 539 } // if 539 540 } // if 540 q->type->forall = nullptr; 541 q->type->forall = nullptr; // forall qualifier moved 541 542 } // if 542 543 -
src/Parser/parser.yy
r0cf5b79 rfdd3786 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Oct 25 12:28:54201713 // Update Count : 2 89312 // Last Modified On : Mon Nov 20 09:45:36 2017 13 // Update Count : 2945 14 14 // 15 15 … … 114 114 } // for 115 115 } // distExt 116 117 // There is an ambiguity for inline generic-routine return-types and generic routines. 118 // forall( otype T ) struct S { int i; } bar( T ) {} 119 // Does the forall bind to the struct or the routine, and how would it be possible to explicitly specify the binding. 120 // forall( otype T ) struct S { int T; } forall( otype W ) bar( W ) {} 121 122 void rebindForall( DeclarationNode * declSpec, DeclarationNode * funcDecl ) { 123 if ( declSpec->type->kind == TypeData::Aggregate ) { // return is aggregate definition 124 funcDecl->type->forall = declSpec->type->aggregate.params; // move forall from aggregate to function type 125 declSpec->type->aggregate.params = nullptr; 126 } // if 127 } // rebindForall 116 128 117 129 bool forall = false; // aggregate have one or more forall qualifiers ? … … 348 360 349 361 350 // Handle single shift/reduce conflict for dangling else by shifting the ELSE token. For example, this string 351 // is ambiguous: 352 // .---------. matches IF '(' comma_expression ')' statement . (reduce) 353 // if ( C ) S1 else S2 354 // `-----------------' matches IF '(' comma_expression ')' statement . (shift) ELSE statement */ 362 // Handle shift/reduce conflict for dangling else by shifting the ELSE token. For example, this string is ambiguous: 363 // .---------. matches IF '(' comma_expression ')' statement . (reduce) 364 // if ( C ) S1 else S2 365 // `-----------------' matches IF '(' comma_expression ')' statement . (shift) ELSE statement */ 355 366 // Similar issues exit with the waitfor statement. 356 367 … … 361 372 %precedence TIMEOUT // token precedence for start of TIMEOUT in WAITFOR statement 362 373 %precedence ELSE // token precedence for start of else clause in IF/WAITFOR statement 374 375 // Handle shift/reduce conflict for generic type by shifting the '(' token. For example, this string is ambiguous: 376 // forall( otype T ) struct Foo { T v; }; 377 // .-----. matches pointer to function returning a generic (which is impossible without a type) 378 // Foo ( *fp )( int ); 379 // `---' matches start of TYPEGENname '(' 380 // Must be: 381 // Foo( int ) ( *fp )( int ); 382 383 // Order of these lines matters (low-to-high precedence). 384 %precedence TYPEGENname 385 %precedence '(' 363 386 364 387 %locations // support location tracking for error messages … … 1765 1788 1766 1789 typegen_name: // CFA 1767 TYPEGENname '(' ')' 1790 TYPEGENname 1791 { $$ = DeclarationNode::newFromTypeGen( $1, nullptr ); } 1792 | TYPEGENname '(' ')' 1768 1793 { $$ = DeclarationNode::newFromTypeGen( $1, nullptr ); } 1769 1794 | TYPEGENname '(' type_list ')' … … 1809 1834 } 1810 1835 | aggregate_key attribute_list_opt typegen_name // CFA 1811 { $$ = $3->addQualifiers( $2 ); } 1836 { 1837 // Create new generic declaration with same name as previous forward declaration, where the IDENTIFIER is 1838 // switched to a TYPEGENname. Link any generic arguments from typegen_name to new generic declaration and 1839 // delete newFromTypeGen. 1840 $$ = DeclarationNode::newAggregate( $1, $3->type->symbolic.name, $3->type->symbolic.actuals, nullptr, false )->addQualifiers( $2 ); 1841 $3->type->symbolic.name = nullptr; 1842 $3->type->symbolic.actuals = nullptr; 1843 delete $3; 1844 } 1812 1845 ; 1813 1846 … … 2380 2413 | declaration_specifier function_declarator with_clause_opt compound_statement 2381 2414 { 2415 rebindForall( $1, $2 ); 2382 2416 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2383 2417 typedefTable.leaveScope(); … … 2406 2440 | declaration_specifier KR_function_declarator KR_declaration_list_opt with_clause_opt compound_statement 2407 2441 { 2442 rebindForall( $1, $2 ); 2408 2443 typedefTable.addToEnclosingScope( TypedefTable::ID ); 2409 2444 typedefTable.leaveScope(); -
src/SymTab/Validate.cc
r0cf5b79 rfdd3786 423 423 } 424 424 425 void checkGenericParameters( ReferenceToType * inst ) { 426 for ( Expression * param : inst->parameters ) { 427 if ( ! dynamic_cast< TypeExpr * >( param ) ) { 428 throw SemanticError( "Expression parameters for generic types are currently unsupported: ", inst ); 429 } 430 } 431 } 432 425 433 void LinkReferenceToTypes::postvisit( StructInstType *structInst ) { 426 434 StructDecl *st = local_indexer->lookupStruct( structInst->get_name() ); … … 434 442 forwardStructs[ structInst->get_name() ].push_back( structInst ); 435 443 } // if 444 checkGenericParameters( structInst ); 436 445 } 437 446 … … 446 455 forwardUnions[ unionInst->get_name() ].push_back( unionInst ); 447 456 } // if 457 checkGenericParameters( unionInst ); 448 458 } 449 459 … … 525 535 // need to carry over the 'sized' status of each decl in the instance 526 536 for ( auto p : group_iterate( traitDecl->get_parameters(), traitInst->get_parameters() ) ) { 527 TypeExpr * expr = strict_dynamic_cast< TypeExpr * >( std::get<1>(p) ); 537 TypeExpr * expr = dynamic_cast< TypeExpr * >( std::get<1>(p) ); 538 if ( ! expr ) { 539 throw SemanticError( "Expression parameters for trait instances are currently unsupported: ", std::get<1>(p) ); 540 } 528 541 if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( expr->get_type() ) ) { 529 542 TypeDecl * formalDecl = std::get<0>(p); -
src/benchmark/Makefile.am
r0cf5b79 rfdd3786 24 24 repeats = 30 25 25 TIME_FORMAT = "%E" 26 PRINT_FORMAT = '%20s\t'26 PRINT_FORMAT = %20s: #Comments needed for spacing 27 27 28 28 .NOTPARALLEL: … … 217 217 218 218 compile-array$(EXEEXT): 219 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/array.c 219 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/array.c @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 220 220 221 221 compile-attributes$(EXEEXT): 222 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/attributes.c 222 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/attributes.c @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 223 223 224 224 compile-empty$(EXEEXT): 225 @${CC} -nodebug -quiet -fsyntax-only -w compile/empty.c 225 @${CC} -nodebug -quiet -fsyntax-only -w compile/empty.c @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 226 226 227 227 compile-expression$(EXEEXT): 228 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/expression.c 228 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/expression.c @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 229 229 230 230 compile-io$(EXEEXT): 231 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/io.c 231 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/io.c @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 232 232 233 233 compile-monitor$(EXEEXT): 234 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/monitor.c 234 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/monitor.c @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 235 235 236 236 compile-operators$(EXEEXT): 237 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/operators.c 237 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/operators.c @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 238 238 239 239 compile-thread$(EXEEXT): 240 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/thread.c 240 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/thread.c @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 241 241 242 242 compile-typeof$(EXEEXT): 243 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/typeof.c 244 243 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/typeof.c @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 244 -
src/benchmark/Makefile.in
r0cf5b79 rfdd3786 254 254 repeats = 30 255 255 TIME_FORMAT = "%E" 256 PRINT_FORMAT = '%20s\t'256 PRINT_FORMAT = %20s: #Comments needed for spacing 257 257 all: all-am 258 258 … … 623 623 624 624 compile-array$(EXEEXT): 625 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/array.c 625 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/array.c @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 626 626 627 627 compile-attributes$(EXEEXT): 628 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/attributes.c 628 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/attributes.c @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 629 629 630 630 compile-empty$(EXEEXT): 631 @${CC} -nodebug -quiet -fsyntax-only -w compile/empty.c 631 @${CC} -nodebug -quiet -fsyntax-only -w compile/empty.c @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 632 632 633 633 compile-expression$(EXEEXT): 634 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/expression.c 634 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/expression.c @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 635 635 636 636 compile-io$(EXEEXT): 637 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/io.c 637 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/io.c @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 638 638 639 639 compile-monitor$(EXEEXT): 640 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/monitor.c 640 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/monitor.c @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 641 641 642 642 compile-operators$(EXEEXT): 643 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/operators.c 643 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/operators.c @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 644 644 645 645 compile-thread$(EXEEXT): 646 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/thread.c 646 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/thread.c @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 647 647 648 648 compile-typeof$(EXEEXT): 649 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/typeof.c 649 @${CC} -nodebug -quiet -fsyntax-only -w ../tests/typeof.c @CFA_FLAGS@ ${AM_CFLAGS} ${CFLAGS} ${ccflags} 650 650 651 651 # Tell versions [3.59,3.63) of GNU make to not export all variables.
Note: See TracChangeset
for help on using the changeset viewer.