Changes in / [7c70089:b32ada31]
- Files:
-
- 35 edited
-
doc/LaTeXmacros/common.tex (modified) (1 diff)
-
src/CodeGen/CodeGenerator.cc (modified) (2 diffs)
-
src/CodeGen/GenType.cc (modified) (3 diffs)
-
src/Concurrency/Keywords.cc (modified) (3 diffs)
-
src/GenPoly/Box.cc (modified) (2 diffs)
-
src/GenPoly/Lvalue.cc (modified) (3 diffs)
-
src/GenPoly/ScrubTyVars.cc (modified) (2 diffs)
-
src/InitTweak/FixInit.cc (modified) (12 diffs)
-
src/InitTweak/GenInit.cc (modified) (3 diffs)
-
src/Parser/DeclarationNode.cc (modified) (14 diffs)
-
src/Parser/ExpressionNode.cc (modified) (1 diff)
-
src/Parser/ParseNode.h (modified) (1 diff)
-
src/Parser/TypeData.cc (modified) (2 diffs)
-
src/Parser/lex.ll (modified) (2 diffs)
-
src/Parser/parser.yy (modified) (5 diffs)
-
src/ResolvExpr/AlternativeFinder.cc (modified) (3 diffs)
-
src/ResolvExpr/CommonType.cc (modified) (10 diffs)
-
src/ResolvExpr/Unify.cc (modified) (3 diffs)
-
src/SymTab/Autogen.cc (modified) (2 diffs)
-
src/SymTab/Autogen.h (modified) (2 diffs)
-
src/SymTab/ImplementationType.cc (modified) (3 diffs)
-
src/SymTab/Mangler.cc (modified) (3 diffs)
-
src/SymTab/Validate.cc (modified) (3 diffs)
-
src/SynTree/ArrayType.cc (modified) (2 diffs)
-
src/SynTree/Declaration.cc (modified) (1 diff)
-
src/SynTree/Expression.cc (modified) (4 diffs)
-
src/SynTree/Initializer.cc (modified) (1 diff)
-
src/SynTree/Initializer.h (modified) (1 diff)
-
src/SynTree/TupleExpr.cc (modified) (2 diffs)
-
src/SynTree/Type.cc (modified) (5 diffs)
-
src/SynTree/Type.h (modified) (7 diffs)
-
src/SynTree/TypeSubstitution.cc (modified) (2 diffs)
-
src/Tuples/TupleAssignment.cc (modified) (2 diffs)
-
src/Tuples/TupleExpansion.cc (modified) (3 diffs)
-
src/tests/.expect/memberCtors-ERR1.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
doc/LaTeXmacros/common.tex
r7c70089 rb32ada31 40 40 \newcommand{\CC}{\rm C\kern-.1em\hbox{+\kern-.25em+}\xspace} % CC symbolic name 41 41 \newcommand{\CCeleven}{\rm C\kern-.1em\hbox{+\kern-.25em+}11\xspace} % C++11 symbolic name 42 \newcommand{\CCfourteen}{\rm C\kern-.1em\hbox{+\kern-.25em+}14\xspace} % C++14 symbolic name43 42 \newcommand{\CCseventeen}{\rm C\kern-.1em\hbox{+\kern-.25em+}17\xspace} % C++17 symbolic name 44 43 \newcommand{\Celeven}{C11\xspace} % C11 symbolic name -
src/CodeGen/CodeGenerator.cc
r7c70089 rb32ada31 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 09:06:01201713 // Update Count : 48 112 // Last Modified On : Thu Mar 16 09:09:09 2017 13 // Update Count : 480 14 14 // 15 15 … … 539 539 if ( castExpr->get_result()->isVoid() ) { 540 540 output << "(void)" ; 541 } else if ( ! castExpr->get_result()->get_ lvalue() ) {541 } else if ( ! castExpr->get_result()->get_isLvalue() ) { 542 542 // at least one result type of cast, but not an lvalue 543 543 output << "("; -
src/CodeGen/GenType.cc
r7c70089 rb32ada31 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 09:02:28201713 // Update Count : 2 212 // Last Modified On : Thu Feb 2 13:53:43 2017 13 // Update Count : 20 14 14 // 15 15 … … 99 99 os << "static "; 100 100 } // if 101 if ( qualifiers.is _const ) {101 if ( qualifiers.isConst ) { 102 102 os << "const "; 103 103 } // if 104 if ( qualifiers.is _volatile ) {104 if ( qualifiers.isVolatile ) { 105 105 os << "volatile "; 106 106 } // if 107 if ( qualifiers.is _restrict ) {107 if ( qualifiers.isRestrict ) { 108 108 os << "__restrict "; 109 109 } // if 110 if ( qualifiers.is _atomic ) {110 if ( qualifiers.isAtomic ) { 111 111 os << "_Atomic "; 112 112 } // if … … 238 238 239 239 void GenType::handleQualifiers( Type *type ) { 240 if ( type->get_ const() ) {240 if ( type->get_isConst() ) { 241 241 typeString = "const " + typeString; 242 242 } // if 243 if ( type->get_ volatile() ) {243 if ( type->get_isVolatile() ) { 244 244 typeString = "volatile " + typeString; 245 245 } // if 246 if ( type->get_ restrict() ) {246 if ( type->get_isRestrict() ) { 247 247 typeString = "__restrict " + typeString; 248 248 } // if 249 if ( type->get_ atomic() ) {249 if ( type->get_isAtomic() ) { 250 250 typeString = "_Atomic " + typeString; 251 251 } // if -
src/Concurrency/Keywords.cc
r7c70089 rb32ada31 12 12 // Last Modified By : 13 13 // Last Modified On : 14 // Update Count : 314 // Update Count : 1 15 15 // 16 16 … … 264 264 //Find mutex arguments 265 265 Type* ty = arg->get_type(); 266 if( ! ty->get_ mutex()) continue;266 if( ! ty->get_qualifiers().isMutex ) continue; 267 267 268 268 //Append it to the list … … 285 285 286 286 //Make sure that typed isn't mutex 287 if( ! base->get_mutex()) throw SemanticError( "mutex keyword may only appear once per argument ", arg );287 if( base->get_qualifiers().isMutex ) throw SemanticError( "mutex keyword may only appear once per argument ", arg ); 288 288 } 289 289 -
src/GenPoly/Box.cc
r7c70089 rb32ada31 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 09:06:37201713 // Update Count : 33 912 // Last Modified On : Thu Mar 16 08:35:33 2017 13 // Update Count : 338 14 14 // 15 15 … … 753 753 // if the argument's type is polymorphic, we don't need to box again! 754 754 return; 755 } else if ( arg->get_result()->get_ lvalue() ) {755 } else if ( arg->get_result()->get_isLvalue() ) { 756 756 // VariableExpr and MemberExpr are lvalues; need to check this isn't coming from the second arg of a comma expression though (not an lvalue) 757 757 // xxx - need to test that this code is still reachable -
src/GenPoly/Lvalue.cc
r7c70089 rb32ada31 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 09:11:18 201713 // Update Count : 512 // Last Modified On : Tue Dec 15 15:33:13 2015 13 // Update Count : 3 14 14 // 15 15 … … 79 79 if ( function->get_returnVals().empty() ) return 0; 80 80 Type *ty = function->get_returnVals().front()->get_type(); 81 return ty->get_ lvalue() ? ty : 0;81 return ty->get_isLvalue() ? ty : 0; 82 82 } 83 83 … … 134 134 Statement * Pass1::mutate(ReturnStmt *retStmt) { 135 135 if ( retval && retStmt->get_expr() ) { 136 if ( retStmt->get_expr()->get_result()->get_ lvalue() ) {136 if ( retStmt->get_expr()->get_result()->get_isLvalue() ) { 137 137 // ***** Code Removal ***** because casts may be stripped already 138 138 -
src/GenPoly/ScrubTyVars.cc
r7c70089 rb32ada31 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Mar 16 15:44:27 201713 // Update Count : 312 // Last Modified On : Tue May 19 16:42:42 2015 13 // Update Count : 2 14 14 // 15 15 … … 109 109 if ( Type *dynType = shouldScrub( pointer->get_base() ) ) { 110 110 Type *ret = dynType->acceptMutator( *this ); 111 ret->get_qualifiers() |= pointer->get_qualifiers();111 ret->get_qualifiers() += pointer->get_qualifiers(); 112 112 pointer->set_base( 0 ); 113 113 delete pointer; -
src/InitTweak/FixInit.cc
r7c70089 rb32ada31 10 10 // Created On : Wed Jan 13 16:29:30 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 09:13:47201713 // Update Count : 7112 // Last Modified On : Thu Mar 16 08:08:04 2017 13 // Update Count : 67 14 14 // 15 15 … … 232 232 void handleFirstParam( Expression * firstParam ); 233 233 template< typename... Params > 234 void emit( CodeLocation,const Params &... params );234 void emit( const Params &... params ); 235 235 236 236 FunctionDecl * function = 0; 237 std::set< DeclarationWithType * > unhandled; 238 std::map< DeclarationWithType *, CodeLocation > usedUninit; 237 std::set< DeclarationWithType * > unhandled, usedUninit; 239 238 ObjectDecl * thisParam = 0; 240 239 bool isCtor = false; // true if current function is a constructor … … 337 336 GenStructMemberCalls warner; 338 337 acceptAll( translationUnit, warner ); 338 339 // visitor doesn't throw so that it can collect all errors 340 if ( ! warner.errors.isEmpty() ) { 341 throw warner.errors; 342 } 339 343 } 340 344 … … 434 438 env->apply( result ); 435 439 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), Type::StorageClasses(), LinkageSpec::C, 0, result, 0 ); 436 tmp->get_type()->set_ const( false );440 tmp->get_type()->set_isConst( false ); 437 441 438 442 // create and resolve copy constructor … … 480 484 env->apply( result ); 481 485 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), Type::StorageClasses(), LinkageSpec::C, 0, result, 0 ); 482 ret->get_type()->set_ const( false );486 ret->get_type()->set_isConst( false ); 483 487 impCpCtorExpr->get_returnDecls().push_back( ret ); 484 488 CP_CTOR_PRINT( std::cerr << "makeCtorDtor for a return" << std::endl; ) 485 if ( ! result->get_ lvalue() ) {489 if ( ! result->get_isLvalue() ) { 486 490 // destructing lvalue returns is bad because it can cause multiple destructor calls to the same object - the returned object is not a temporary 487 491 destructRet( ret, impCpCtorExpr ); … … 503 507 env->apply( result ); 504 508 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), Type::StorageClasses(), LinkageSpec::C, 0, result, 0 ); 505 ret->get_type()->set_ const( false );509 ret->get_type()->set_isConst( false ); 506 510 stmtExpr->get_returnDecls().push_front( ret ); 507 511 … … 584 588 585 589 Expression * retExpr = new CommaExpr( assign, new VariableExpr( returnDecl ) ); 586 if ( callExpr->get_result()->get_ lvalue() ) {590 if ( callExpr->get_result()->get_isLvalue() ) { 587 591 // lvalue returning functions are funny. Lvalue.cc inserts a *? in front of any lvalue returning 588 592 // non-intrinsic function. Add an AddressExpr to the call to negate the derefence and change the … … 936 940 ValueGuard< FunctionDecl * > oldFunction( funcDecl ); 937 941 ValueGuard< std::set< DeclarationWithType * > > oldUnhandled( unhandled ); 938 ValueGuard< std:: map< DeclarationWithType *, CodeLocation> > oldUsedUninit( usedUninit );942 ValueGuard< std::set< DeclarationWithType * > > oldUsedUninit( usedUninit ); 939 943 ValueGuard< ObjectDecl * > oldThisParam( thisParam ); 940 944 ValueGuard< bool > oldIsCtor( isCtor ); 941 945 ValueGuard< StructDecl * > oldStructDecl( structDecl ); 942 errors = SemanticError(); // clear previous errors943 946 944 947 // need to start with fresh sets … … 969 972 // remove the unhandled objects from usedUninit, because a call is inserted 970 973 // to handle them - only objects that are later constructed are used uninitialized. 971 std::map< DeclarationWithType *, CodeLocation > diff; 972 // need the comparator since usedUninit and unhandled have different types 973 struct comp_t { 974 typedef decltype(usedUninit)::value_type usedUninit_t; 975 typedef decltype(unhandled)::value_type unhandled_t; 976 bool operator()(usedUninit_t x, unhandled_t y) { return x.first < y; } 977 bool operator()(unhandled_t x, usedUninit_t y) { return x < y.first; } 978 } comp; 979 std::set_difference( usedUninit.begin(), usedUninit.end(), unhandled.begin(), unhandled.end(), std::inserter( diff, diff.begin() ), comp ); 980 for ( auto p : diff ) { 981 DeclarationWithType * member = p.first; 982 CodeLocation loc = p.second; 983 // xxx - make error message better by also tracking the location that the object is constructed at? 984 emit( loc, "in ", CodeGen::genPrettyType( function->get_functionType(), function->get_name() ), ", field ", member->get_name(), " used before being constructed" ); 974 std::set< DeclarationWithType * > diff; 975 std::set_difference( usedUninit.begin(), usedUninit.end(), unhandled.begin(), unhandled.end(), std::inserter( diff, diff.begin() ) ); 976 for ( DeclarationWithType * member : diff ) { 977 emit( "in ", CodeGen::genPrettyType( function->get_functionType(), function->get_name() ), ", field ", member->get_name(), " used before being constructed" ); 985 978 } 986 979 … … 1027 1020 } 1028 1021 } catch ( SemanticError & error ) { 1029 emit( funcDecl->location,"in ", CodeGen::genPrettyType( function->get_functionType(), function->get_name() ), ", field ", field->get_name(), " not explicitly ", isCtor ? "constructed" : "destructed", " and no ", isCtor ? "default constructor" : "destructor", " found" );1022 emit( "in ", CodeGen::genPrettyType( function->get_functionType(), function->get_name() ), ", field ", field->get_name(), " not explicitly ", isCtor ? "constructed" : "destructed", " and no ", isCtor ? "default constructor" : "destructor", " found" ); 1030 1023 } 1031 1024 } 1032 1025 } 1033 1026 leaveScope(); 1034 }1035 if (! errors.isEmpty()) {1036 throw errors;1037 1027 } 1038 1028 } … … 1089 1079 if ( unhandled.count( memberExpr->get_member() ) ) { 1090 1080 // emit a warning because a member was used before it was constructed 1091 usedUninit.insert( { memberExpr->get_member(), memberExpr->location });1081 usedUninit.insert( memberExpr->get_member() ); 1092 1082 } 1093 1083 } … … 1099 1089 1100 1090 template< typename Visitor, typename... Params > 1101 void error( Visitor & v, CodeLocation loc, const Params &... params ) { 1102 SemanticError err( toString( params... ) ); 1103 err.set_location( loc ); 1104 v.errors.append( err ); 1091 void error( Visitor & v, const Params &... params ) { 1092 v.errors.append( toString( params... ) ); 1105 1093 } 1106 1094 1107 1095 template< typename... Params > 1108 void GenStructMemberCalls::emit( CodeLocation loc,const Params &... params ) {1096 void GenStructMemberCalls::emit( const Params &... params ) { 1109 1097 // toggle warnings vs. errors here. 1110 1098 // warn( params... ); 1111 error( *this, loc,params... );1099 error( *this, params... ); 1112 1100 } 1113 1101 -
src/InitTweak/GenInit.cc
r7c70089 rb32ada31 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 09:12:36201713 // Update Count : 18 312 // Last Modified On : Thu Mar 16 08:01:25 2017 13 // Update Count : 181 14 14 // 15 15 … … 143 143 // is being returned 144 144 // Note: under the assumption that assignments return *this, checking for ?=? here is an optimization, since it shouldn't be necessary to copy construct `this`. This is a temporary optimization until reference types are added, at which point this should be removed, along with the analogous optimization in copy constructor generation. 145 if ( returnStmt->get_expr() && returnVals.size() == 1 && funcName != "?=?" && ! returnVals.front()->get_type()->get_ lvalue() ) {145 if ( returnStmt->get_expr() && returnVals.size() == 1 && funcName != "?=?" && ! returnVals.front()->get_type()->get_isLvalue() ) { 146 146 // explicitly construct the return value using the return expression and the retVal object 147 147 assertf( returnVals.front()->get_name() != "", "Function %s has unnamed return value\n", funcName.c_str() ); … … 195 195 196 196 ObjectDecl * arrayDimension = new ObjectDecl( dimensionName.newName(), storageClasses, LinkageSpec::C, 0, SymTab::SizeType->clone(), new SingleInit( arrayType->get_dimension() ) ); 197 arrayDimension->get_type()->set_ const( true );197 arrayDimension->get_type()->set_isConst( true ); 198 198 199 199 arrayType->set_dimension( new VariableExpr( arrayDimension ) ); -
src/Parser/DeclarationNode.cc
r7c70089 rb32ada31 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 08:46:05201713 // Update Count : 10 1712 // Last Modified On : Thu Mar 16 09:10:57 2017 13 // Update Count : 1007 14 14 // 15 15 … … 19 19 #include <algorithm> 20 20 #include <cassert> 21 #include <strings.h> // ffs 21 22 22 23 #include "TypeData.h" … … 242 243 243 244 DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) { 244 assert( name );245 245 DeclarationNode * newnode = new DeclarationNode; 246 246 newnode->type = new TypeData( TypeData::Aggregate ); 247 247 newnode->type->aggregate.kind = kind; 248 newnode->type->aggregate.name = name; 248 if ( name ) { 249 newnode->type->aggregate.name = name; 250 } else { // anonymous aggregate ? 251 newnode->type->aggregate.name = new string( anonymous.newName() ); 252 } // if 249 253 newnode->type->aggregate.actuals = actuals; 250 254 newnode->type->aggregate.fields = fields; … … 254 258 255 259 DeclarationNode * DeclarationNode::newEnum( string * name, DeclarationNode * constants, bool body ) { 256 assert( name );257 260 DeclarationNode * newnode = new DeclarationNode; 258 261 newnode->type = new TypeData( TypeData::Enum ); 259 newnode->type->enumeration.name = name; 262 if ( name ) { 263 newnode->type->enumeration.name = name; 264 } else { // anonymous aggregate ? 265 newnode->type->enumeration.name = new string( anonymous.newName() ); 266 } // if 260 267 newnode->type->enumeration.constants = constants; 261 268 newnode->type->enumeration.body = body; … … 429 436 const Type::Qualifiers qsrc = src->qualifiers, qdst = dst->qualifiers; // optimization 430 437 431 if ( (qsrc & qdst).any() ) {// duplicates ?438 if ( (qsrc.val & qdst.val) != 0 ) { // duplicates ? 432 439 for ( unsigned int i = 0; i < Type::NumTypeQualifier; i += 1 ) { // find duplicates 433 440 if ( qsrc[i] && qdst[i] ) { 434 appendError( error, string( "duplicate " ) + Type::Qualifiers Names[i] );441 appendError( error, string( "duplicate " ) + Type::Qualifiers::Names[i] ); 435 442 } // if 436 443 } // for … … 439 446 440 447 void DeclarationNode::checkSpecifiers( DeclarationNode * src ) { 441 if ( (funcSpecs & src->funcSpecs).any() ) {// duplicates ?448 if ( (funcSpecs.val & src->funcSpecs.val) != 0 ) { // duplicates ? 442 449 for ( unsigned int i = 0; i < Type::NumFuncSpecifier; i += 1 ) { // find duplicates 443 450 if ( funcSpecs[i] && src->funcSpecs[i] ) { 444 appendError( error, string( "duplicate " ) + Type::FuncSpecifiers Names[i] );451 appendError( error, string( "duplicate " ) + Type::FuncSpecifiers::Names[i] ); 445 452 } // if 446 453 } // for … … 448 455 449 456 if ( storageClasses.any() && src->storageClasses.any() ) { // any reason to check ? 450 if ( (storageClasses & src->storageClasses ).any()) { // duplicates ?457 if ( (storageClasses.val & src->storageClasses.val ) != 0 ) { // duplicates ? 451 458 for ( unsigned int i = 0; i < Type::NumStorageClass; i += 1 ) { // find duplicates 452 459 if ( storageClasses[i] && src->storageClasses[i] ) { 453 appendError( error, string( "duplicate " ) + Type::StorageClasses Names[i] );460 appendError( error, string( "duplicate " ) + Type::StorageClasses::Names[i] ); 454 461 } // if 455 462 } // for 456 463 // src is the new item being added and has a single bit 457 464 } else if ( ! src->storageClasses.is_threadlocal ) { // conflict ? 458 appendError( error, string( "conflicting " ) + Type::StorageClasses Names[storageClasses.ffs()] +459 " & " + Type::StorageClasses Names[src->storageClasses.ffs()] );460 src->storageClasses. reset(); // FIX to preserve invariant of one basic storage specifier465 appendError( error, string( "conflicting " ) + Type::StorageClasses::Names[ffs( storageClasses.val ) - 1] + 466 " & " + Type::StorageClasses::Names[ffs( src->storageClasses.val ) - 1] ); 467 src->storageClasses.val = 0; // FIX to preserve invariant of one basic storage specifier 461 468 } // if 462 469 } // if … … 466 473 467 474 DeclarationNode * DeclarationNode::copySpecifiers( DeclarationNode * q ) { 468 funcSpecs |= q->funcSpecs;469 storageClasses |= q->storageClasses;475 funcSpecs.val |= q->funcSpecs.val; 476 storageClasses.val |= q->storageClasses.val; 470 477 471 478 for ( Attribute *attr: reverseIterate( q->attributes ) ) { … … 490 497 src = nullptr; 491 498 } else { 492 dst->qualifiers |= src->qualifiers;499 dst->qualifiers += src->qualifiers; 493 500 } // if 494 501 } // addQualifiersToType … … 548 555 switch ( dst->kind ) { 549 556 case TypeData::Unknown: 550 src->qualifiers |= dst->qualifiers;557 src->qualifiers += dst->qualifiers; 551 558 dst = src; 552 559 src = nullptr; 553 560 break; 554 561 case TypeData::Basic: 555 dst->qualifiers |= src->qualifiers;562 dst->qualifiers += src->qualifiers; 556 563 if ( src->kind != TypeData::Unknown ) { 557 564 assert( src->kind == TypeData::Basic ); … … 589 596 dst->base->aggInst.params = maybeClone( src->aggregate.actuals ); 590 597 } // if 591 dst->base->qualifiers |= src->qualifiers;598 dst->base->qualifiers += src->qualifiers; 592 599 src = nullptr; 593 600 break; … … 621 628 type->aggInst.hoistType = o->type->enumeration.body; 622 629 } // if 623 type->qualifiers |= o->type->qualifiers;630 type->qualifiers += o->type->qualifiers; 624 631 } else { 625 632 type = o->type; … … 777 784 p->type->base->aggInst.params = maybeClone( type->aggregate.actuals ); 778 785 } // if 779 p->type->base->qualifiers |= type->qualifiers;786 p->type->base->qualifiers += type->qualifiers; 780 787 break; 781 788 … … 814 821 lastArray->base->aggInst.params = maybeClone( type->aggregate.actuals ); 815 822 } // if 816 lastArray->base->qualifiers |= type->qualifiers;823 lastArray->base->qualifiers += type->qualifiers; 817 824 break; 818 825 default: -
src/Parser/ExpressionNode.cc
r7c70089 rb32ada31 254 254 Expression *build_pfieldSel( ExpressionNode *expr_node, Expression *member ) { 255 255 UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) ); 256 deref->location = expr_node->location;257 256 deref->get_args().push_back( maybeMoveBuild< Expression >(expr_node) ); 258 257 UntypedMemberExpr *ret = new UntypedMemberExpr( member, deref ); -
src/Parser/ParseNode.h
r7c70089 rb32ada31 134 134 Expression * p = orig->build(); 135 135 p->set_extension( orig->get_extension() ); 136 p->location = orig->location;137 136 return p; 138 137 } else { -
src/Parser/TypeData.cc
r7c70089 rb32ada31 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 08:46:10201713 // Update Count : 5 6012 // Last Modified On : Thu Mar 16 08:32:42 2017 13 // Update Count : 559 14 14 // 15 15 … … 227 227 void TypeData::print( ostream &os, int indent ) const { 228 228 for ( int i = 0; i < Type::NumTypeQualifier; i += 1 ) { 229 if ( qualifiers[i] ) os << Type::Qualifiers Names[ i ] << ' ';229 if ( qualifiers[i] ) os << Type::Qualifiers::Names[ i ] << ' '; 230 230 } // for 231 231 -
src/Parser/lex.ll
r7c70089 rb32ada31 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Mon Mar 13 08:36:17201713 * Update Count : 50 612 * Last Modified On : Thu Mar 9 21:38:26 2017 13 * Update Count : 505 14 14 */ 15 15 … … 313 313 314 314 /* punctuation */ 315 "@" { ASCIIOP_RETURN(); }316 315 "[" { ASCIIOP_RETURN(); } 317 316 "]" { ASCIIOP_RETURN(); } -
src/Parser/parser.yy
r7c70089 rb32ada31 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 16 12:57:03201713 // Update Count : 231 612 // Last Modified On : Thu Mar 16 08:36:17 2017 13 // Update Count : 2310 14 14 // 15 15 … … 1612 1612 aggregate_type: // struct, union 1613 1613 aggregate_key attribute_list_opt '{' field_declaration_list '}' 1614 { $$ = DeclarationNode::newAggregate( $1, n ew string( DeclarationNode::anonymous.newName() ), nullptr, $4, true )->addQualifiers( $2 ); }1614 { $$ = DeclarationNode::newAggregate( $1, nullptr, nullptr, $4, true )->addQualifiers( $2 ); } 1615 1615 | aggregate_key attribute_list_opt no_attr_identifier_or_type_name 1616 1616 { typedefTable.makeTypedef( *$3 ); } … … 1618 1618 { $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $6, true )->addQualifiers( $2 ); } 1619 1619 | aggregate_key attribute_list_opt '(' type_name_list ')' '{' field_declaration_list '}' // CFA 1620 { $$ = DeclarationNode::newAggregate( $1, n ew string( DeclarationNode::anonymous.newName() ), $4, $7, false )->addQualifiers( $2 ); }1620 { $$ = DeclarationNode::newAggregate( $1, nullptr, $4, $7, false )->addQualifiers( $2 ); } 1621 1621 | aggregate_type_nobody 1622 1622 ; … … 1688 1688 // empty 1689 1689 { $$ = DeclarationNode::newName( 0 ); /* XXX */ } // CFA, no field name 1690 // '@' 1691 // { $$ = DeclarationNode::newName( new string( DeclarationNode::anonymous.newName() ) );} // CFA, no field name1690 // '@' // empty 1691 // { $$ = DeclarationNode::newName( 0 ); /* XXX */ } // CFA, no field name 1692 1692 | bit_subrange_size // no field name 1693 1693 { $$ = DeclarationNode::newBitfield( $1 ); } … … 1715 1715 enum_type: // enum 1716 1716 ENUM attribute_list_opt '{' enumerator_list comma_opt '}' 1717 { $$ = DeclarationNode::newEnum( n ew string( DeclarationNode::anonymous.newName() ), $4, true )->addQualifiers( $2 ); }1717 { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); } 1718 1718 | ENUM attribute_list_opt no_attr_identifier_or_type_name 1719 1719 { typedefTable.makeTypedef( *$3 ); } -
src/ResolvExpr/AlternativeFinder.cc
r7c70089 rb32ada31 10 10 // Created On : Sat May 16 23:52:08 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 09:14:17 201713 // Update Count : 3012 // Last Modified On : Mon Jul 4 17:02:51 2016 13 // Update Count : 29 14 14 // 15 15 … … 200 200 } 201 201 202 // Central location to handle gcc extension keyword , etc.for all expression types.202 // Central location to handle gcc extension keyword for all expression types. 203 203 for ( Alternative &iter: alternatives ) { 204 204 iter.expr->set_extension( expr->get_extension() ); 205 iter.expr->location = expr->location;206 205 } // for 207 206 } … … 772 771 bool isLvalue( Expression *expr ) { 773 772 // xxx - recurse into tuples? 774 return expr->has_result() && expr->get_result()->get_ lvalue();773 return expr->has_result() && expr->get_result()->get_isLvalue(); 775 774 } 776 775 -
src/ResolvExpr/CommonType.cc
r7c70089 rb32ada31 10 10 // Created On : Sun May 17 06:59:27 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 16 16:24:31 201713 // Update Count : 712 // Last Modified On : Wed Mar 2 17:35:34 2016 13 // Update Count : 3 14 14 // 15 15 … … 71 71 if ( unifyExact( type1, type->get_base(), env, have, need, newOpen, indexer ) ) { 72 72 result = type1->clone(); 73 result->get_qualifiers() = tq1 |tq2;73 result->get_qualifiers() = tq1 + tq2; 74 74 } // if 75 75 type1->get_qualifiers() = tq1; … … 133 133 BasicType::Kind newType = combinedType[ basicType->get_kind() ][ otherBasic->get_kind() ]; 134 134 if ( ( ( newType == basicType->get_kind() && basicType->get_qualifiers() >= otherBasic->get_qualifiers() ) || widenFirst ) && ( ( newType == otherBasic->get_kind() && basicType->get_qualifiers() <= otherBasic->get_qualifiers() ) || widenSecond ) ) { 135 result = new BasicType( basicType->get_qualifiers() |otherBasic->get_qualifiers(), newType );135 result = new BasicType( basicType->get_qualifiers() + otherBasic->get_qualifiers(), newType ); 136 136 } // if 137 137 } else if ( dynamic_cast< EnumInstType * > ( type2 ) || dynamic_cast< ZeroType* >( type2 ) || dynamic_cast< OneType* >( type2 ) ) { … … 139 139 BasicType::Kind newType = combinedType[ basicType->get_kind() ][ BasicType::SignedInt ]; 140 140 if ( ( ( newType == basicType->get_kind() && basicType->get_qualifiers() >= type2->get_qualifiers() ) || widenFirst ) && ( ( newType != basicType->get_kind() && basicType->get_qualifiers() <= type2->get_qualifiers() ) || widenSecond ) ) { 141 result = new BasicType( basicType->get_qualifiers() |type2->get_qualifiers(), newType );141 result = new BasicType( basicType->get_qualifiers() + type2->get_qualifiers(), newType ); 142 142 } // if 143 143 } // if … … 154 154 } 155 155 result = voidPointer->clone(); 156 result->get_qualifiers() |= otherPointer->get_qualifiers();156 result->get_qualifiers() += otherPointer->get_qualifiers(); 157 157 } 158 158 … … 176 176 result = otherPointer->clone(); 177 177 } // if 178 result->get_qualifiers() = tq1 |tq2;178 result->get_qualifiers() = tq1 + tq2; 179 179 } else { 180 180 /// std::cout << "place for ptr-to-type" << std::endl; … … 185 185 } else if ( widenSecond && dynamic_cast< ZeroType* >( type2 ) ) { 186 186 result = pointerType->clone(); 187 result->get_qualifiers() |= type2->get_qualifiers();187 result->get_qualifiers() += type2->get_qualifiers(); 188 188 } // if 189 189 } … … 230 230 if ( unifyExact( type->get_base(), type2, env, have, need, newOpen, indexer ) ) { 231 231 result = type2->clone(); 232 result->get_qualifiers() = tq1 |tq2;232 result->get_qualifiers() = tq1 + tq2; 233 233 } // if 234 234 type2->get_qualifiers() = tq2; … … 250 250 if ( widenSecond || zeroType->get_qualifiers() <= type2->get_qualifiers() ) { 251 251 result = type2->clone(); 252 result->get_qualifiers() |= zeroType->get_qualifiers();252 result->get_qualifiers() += zeroType->get_qualifiers(); 253 253 } 254 254 } else if ( widenSecond && dynamic_cast< OneType* >( type2 ) ) { 255 255 result = new BasicType( zeroType->get_qualifiers(), BasicType::SignedInt ); 256 result->get_qualifiers() |= type2->get_qualifiers();256 result->get_qualifiers() += type2->get_qualifiers(); 257 257 } 258 258 } … … 264 264 if ( widenSecond || oneType->get_qualifiers() <= type2->get_qualifiers() ) { 265 265 result = type2->clone(); 266 result->get_qualifiers() |= oneType->get_qualifiers();266 result->get_qualifiers() += oneType->get_qualifiers(); 267 267 } 268 268 } else if ( widenSecond && dynamic_cast< ZeroType* >( type2 ) ) { 269 269 result = new BasicType( oneType->get_qualifiers(), BasicType::SignedInt ); 270 result->get_qualifiers() |= type2->get_qualifiers();270 result->get_qualifiers() += type2->get_qualifiers(); 271 271 } 272 272 } -
src/ResolvExpr/Unify.cc
r7c70089 rb32ada31 10 10 // Created On : Sun May 17 12:27:10 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 16 16:22:54201713 // Update Count : 4 212 // Last Modified On : Thu Mar 16 07:59:59 2017 13 // Update Count : 40 14 14 // 15 15 … … 353 353 #endif 354 354 if ( ( common = commonType( type1, type2, widenMode.widenFirst, widenMode.widenSecond, indexer, env, openVars ) ) ) { 355 common->get_qualifiers() = tq1 |tq2;355 common->get_qualifiers() = tq1 + tq2; 356 356 #ifdef DEBUG 357 357 std::cerr << "unifyInexact: common type is "; … … 370 370 if ( ( tq1 > tq2 || widenMode.widenFirst ) && ( tq2 > tq1 || widenMode.widenSecond ) ) { 371 371 common = type1->clone(); 372 common->get_qualifiers() = tq1 |tq2;372 common->get_qualifiers() = tq1 + tq2; 373 373 result = true; 374 374 } else { -
src/SymTab/Autogen.cc
r7c70089 rb32ada31 10 10 // Created On : Thu Mar 03 15:45:56 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 09:41:08201713 // Update Count : 6012 // Last Modified On : Thu Mar 16 08:37:22 2017 13 // Update Count : 59 14 14 // 15 15 … … 323 323 } 324 324 325 if ( type->get_ const()&& func->get_name() == "?=?" ) {325 if ( type->get_qualifiers().isConst && func->get_name() == "?=?" ) { 326 326 // don't assign const members, but do construct/destruct 327 327 continue; -
src/SymTab/Autogen.h
r7c70089 rb32ada31 10 10 // Created On : Sun May 17 21:53:34 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 09:10:41201713 // Update Count : 912 // Last Modified On : Thu Mar 16 07:51:39 2017 13 // Update Count : 8 14 14 // 15 15 … … 60 60 // castType->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, false); 61 61 castType->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic ); 62 castType->set_ lvalue( true ); // xxx - might not need this62 castType->set_isLvalue( true ); // xxx - might not need this 63 63 dstParam = new CastExpr( dstParam, new PointerType( Type::Qualifiers(), castType ) ); 64 64 } -
src/SymTab/ImplementationType.cc
r7c70089 rb32ada31 10 10 // Created On : Sun May 17 21:32:01 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 16 15:54:08 201713 // Update Count : 412 // Last Modified On : Wed Mar 2 17:31:20 2016 13 // Update Count : 3 14 14 // 15 15 … … 105 105 if ( typeDecl && typeDecl->get_base() ) { 106 106 Type *base = implementationType( typeDecl->get_base(), indexer ); 107 base->get_qualifiers() |= inst->get_qualifiers();107 base->get_qualifiers() += inst->get_qualifiers(); 108 108 result = base; 109 109 } // if … … 114 114 for ( std::list< Type* >::iterator i = tupleType->get_types().begin(); i != tupleType->get_types().end(); ++i ) { 115 115 Type *implType = implementationType( *i, indexer ); 116 implType->get_qualifiers() |= tupleType->get_qualifiers();116 implType->get_qualifiers() += tupleType->get_qualifiers(); 117 117 newType->get_types().push_back( implType ); 118 118 } // for -
src/SymTab/Mangler.cc
r7c70089 rb32ada31 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 21:40:29 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Mar 17 09:40:01 201713 // Update Count : 2011 // Last Modified By : Rob Schluntz 12 // Last Modified On : Wed Aug 19 15:52:24 2015 13 // Update Count : 19 14 14 // 15 15 … … 294 294 mangleName << "_"; 295 295 } // if 296 if ( type->get_ const() ) {296 if ( type->get_isConst() ) { 297 297 mangleName << "C"; 298 298 } // if 299 if ( type->get_ volatile() ) {299 if ( type->get_isVolatile() ) { 300 300 mangleName << "V"; 301 301 } // if … … 304 304 // mangleName << "R"; 305 305 // } // if 306 if ( type->get_ lvalue() ) {306 if ( type->get_isLvalue() ) { 307 307 mangleName << "L"; 308 308 } // if 309 if ( type->get_ atomic() ) {309 if ( type->get_isAtomic() ) { 310 310 mangleName << "A"; 311 311 } // if -
src/SymTab/Validate.cc
r7c70089 rb32ada31 10 10 // Created On : Sun May 17 21:50:04 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 16 16:39:15201713 // Update Count : 35 312 // Last Modified On : Thu Mar 16 08:02:54 2017 13 // Update Count : 351 14 14 // 15 15 … … 611 611 if ( def != typedefNames.end() ) { 612 612 Type *ret = def->second.first->get_base()->clone(); 613 ret->get_qualifiers() |= typeInst->get_qualifiers();613 ret->get_qualifiers() += typeInst->get_qualifiers(); 614 614 // place instance parameters on the typedef'd type 615 615 if ( ! typeInst->get_parameters().empty() ) { … … 656 656 // hence the type-name "screen" must be defined. 657 657 // Note, qualifiers on the typedef are superfluous for the forward declaration. 658 659 Type *designatorType = tyDecl->get_base()->stripDeclarator(); 660 if ( StructInstType *aggDecl = dynamic_cast< StructInstType * >( designatorType ) ) { 658 if ( StructInstType *aggDecl = dynamic_cast< StructInstType * >( tyDecl->get_base() ) ) { 661 659 return new StructDecl( aggDecl->get_name() ); 662 } else if ( UnionInstType *aggDecl = dynamic_cast< UnionInstType * >( designatorType) ) {660 } else if ( UnionInstType *aggDecl = dynamic_cast< UnionInstType * >( tyDecl->get_base() ) ) { 663 661 return new UnionDecl( aggDecl->get_name() ); 664 } else if ( EnumInstType *enumDecl = dynamic_cast< EnumInstType * >( designatorType) ) {662 } else if ( EnumInstType *enumDecl = dynamic_cast< EnumInstType * >( tyDecl->get_base() ) ) { 665 663 return new EnumDecl( enumDecl->get_name() ); 666 664 } else { -
src/SynTree/ArrayType.cc
r7c70089 rb32ada31 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 09:40:30201713 // Update Count : 1 312 // Last Modified On : Wed Feb 1 17:16:29 2017 13 // Update Count : 12 14 14 // 15 15 … … 21 21 ArrayType::ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes ) 22 22 : Type( tq, attributes ), base( base ), dimension( dimension ), isVarLen( isVarLen ), isStatic( isStatic ) { 23 base->set_ lvalue( false );23 base->set_isLvalue( false ); 24 24 } 25 25 -
src/SynTree/Declaration.cc
r7c70089 rb32ada31 32 32 33 33 Declaration::Declaration( const Declaration &other ) 34 : BaseSyntaxNode( other ),name( other.name ), storageClasses( other.storageClasses ), linkage( other.linkage ), uniqueId( other.uniqueId ) {34 : name( other.name ), storageClasses( other.storageClasses ), linkage( other.linkage ), uniqueId( other.uniqueId ) { 35 35 } 36 36 -
src/SynTree/Expression.cc
r7c70089 rb32ada31 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 09:42:04 201713 // Update Count : 5112 // Last Modified On : Fri Aug 5 14:23:56 2016 13 // Update Count : 49 14 14 // 15 15 … … 33 33 Expression::Expression( Expression *_aname ) : result( 0 ), env( 0 ), argName( _aname ) {} 34 34 35 Expression::Expression( const Expression &other ) : BaseSyntaxNode( other ),result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) {35 Expression::Expression( const Expression &other ) : result( maybeClone( other.result ) ), env( maybeClone( other.env ) ), argName( maybeClone( other.get_argName() ) ), extension( other.extension ) { 36 36 } 37 37 … … 77 77 assert( var->get_type() ); 78 78 Type * type = var->get_type()->clone(); 79 type->set_ lvalue( true );79 type->set_isLvalue( true ); 80 80 set_result( type ); 81 81 } … … 352 352 sub.apply( res ); 353 353 set_result( res ); 354 get_result()->set_ lvalue( true );354 get_result()->set_isLvalue( true ); 355 355 } 356 356 -
src/SynTree/Initializer.cc
r7c70089 rb32ada31 20 20 21 21 Initializer::Initializer( bool maybeConstructed ) : maybeConstructed( maybeConstructed ) {} 22 Initializer::Initializer( const Initializer & other ) : BaseSyntaxNode( other ),maybeConstructed( other.maybeConstructed ) {22 Initializer::Initializer( const Initializer & other ) : maybeConstructed( other.maybeConstructed ) { 23 23 } 24 24 -
src/SynTree/Initializer.h
r7c70089 rb32ada31 112 112 // ConstructorInit represents an initializer that is either a constructor expression or 113 113 // a C-style initializer. 114 // It should not be necessary to create ConstructorInit nodes manually. Instead, set maybeConstructed115 // to true on SingleInit or ListInit constructors if object should be constructed.116 114 class ConstructorInit : public Initializer { 117 115 public: -
src/SynTree/TupleExpr.cc
r7c70089 rb32ada31 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 09:42:29 201713 // Update Count : 312 // Last Modified On : Mon May 18 10:59:19 2015 13 // Update Count : 1 14 14 // 15 15 … … 60 60 assertf( type->size() > index, "TupleIndexExpr index out of bounds: tuple size %d, requested index %d in expr %s", type->size(), index, toString( tuple ).c_str() ); 61 61 set_result( (*std::next( type->get_types().begin(), index ))->clone() ); 62 get_result()->set_ lvalue( type->get_lvalue() );62 get_result()->set_isLvalue( type->get_isLvalue() ); 63 63 } 64 64 -
src/SynTree/Type.cc
r7c70089 rb32ada31 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 08:42:47201713 // Update Count : 2 812 // Last Modified On : Thu Mar 16 10:25:06 2017 13 // Update Count : 23 14 14 // 15 15 … … 19 19 #include "Declaration.h" 20 20 #include "Attribute.h" 21 #include "InitTweak/InitTweak.h"22 21 #include "Common/utility.h" 23 22 … … 50 49 Type::Type( const Qualifiers &tq, const std::list< Attribute * > & attributes ) : tq( tq ), attributes( attributes ) {} 51 50 52 Type::Type( const Type &other ) : BaseSyntaxNode( other ),tq( other.tq ) {51 Type::Type( const Type &other ) : tq( other.tq ) { 53 52 cloneAll( other.forall, forall ); 54 53 cloneAll( other.attributes, attributes ); … … 61 60 62 61 // These must remain in the same order as the corresponding bit fields. 63 const char * Type::FuncSpecifiersNames[] = { "inline", "fortran", "_Noreturn" }; 64 const char * Type::StorageClassesNames[] = { "extern", "static", "auto", "register", "_Thread_local" }; 65 const char * Type::QualifiersNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" }; 66 67 Type *Type::stripDeclarator() { 68 Type * type = this; 69 while ( Type * at = InitTweak::getPointerBase( type ) ) { 70 type = at; 71 } 72 return type; 73 } 62 const char * Type::FuncSpecifiers::Names[] = { "inline", "fortran", "_Noreturn" }; 63 const char * Type::StorageClasses::Names[] = { "extern", "static", "auto", "register", "_Thread_local" }; 64 const char * Type::Qualifiers::Names[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" }; 74 65 75 66 void Type::print( std::ostream &os, int indent ) const { … … 84 75 printAll( attributes, os, indent+4 ); 85 76 } // if 86 77 87 78 tq.print( os ); 88 79 } -
src/SynTree/Type.h
r7c70089 rb32ada31 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 09:04:03201713 // Update Count : 1 4712 // Last Modified On : Thu Mar 16 12:11:50 2017 13 // Update Count : 116 14 14 // 15 15 … … 21 21 #include "SynTree.h" 22 22 #include "Visitor.h" 23 #include <strings.h> // ffs24 23 25 24 class Type : public BaseSyntaxNode { 26 25 public: 27 // Simulate inheritance because union does not allow it. 28 // Bug in g++-4.9 prevents static field in union 29 //static const char * Names[]; 30 #define BFCommon( BFType, N ) \ 26 #define CommonBF( N ) \ 31 27 bool operator[]( unsigned int i ) const { return val & (1 << i); } \ 32 28 bool any() const { return val != 0; } \ 33 void reset() { val = 0; } \ 34 int ffs() { return ::ffs( val ) - 1; } \ 35 BFType operator&=( BFType other ) { \ 36 val &= other.val; return *this; \ 37 } \ 38 BFType operator&( BFType other ) const { \ 39 BFType q = other; \ 40 q &= *this; \ 41 return q; \ 42 } \ 43 BFType operator|=( BFType other ) { \ 44 val |= other.val; return *this; \ 45 } \ 46 BFType operator|( BFType other ) const { \ 47 BFType q = other; \ 48 q |= *this; \ 49 return q; \ 50 } \ 51 BFType operator-=( BFType other ) { \ 52 val &= ~other.val; return *this; \ 53 } \ 29 static const char * Names[]; \ 54 30 void print( std::ostream & os ) const { \ 55 31 if ( (*this).any() ) { \ 56 32 for ( unsigned int i = 0; i < N; i += 1 ) { \ 57 33 if ( (*this)[i] ) { \ 58 os << BFType##Names[i] << ' '; \34 os << Names[i] << ' '; \ 59 35 } \ 60 36 } \ … … 65 41 66 42 enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NumFuncSpecifier = 3 }; 67 static const char * FuncSpecifiersNames[];68 43 union FuncSpecifiers { 69 44 unsigned int val; … … 75 50 FuncSpecifiers() : val( 0 ) {} 76 51 FuncSpecifiers( unsigned int val ) : val( val ) {} 77 // equality (==, !=) works implicitly on first field "val", relational operations are undefined. 78 BFCommon( FuncSpecifiers, NumFuncSpecifier ) 52 CommonBF( NumFuncSpecifier ) 79 53 }; // FuncSpecifiers 80 54 81 55 enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NumStorageClass = 5 }; 82 static const char * StorageClassesNames[];83 56 union StorageClasses { 84 57 unsigned int val; … … 93 66 StorageClasses() : val( 0 ) {} 94 67 StorageClasses( unsigned int val ) : val( val ) {} 95 // equality (==, !=) works implicitly on first field "val", relational operations are undefined. 96 BFCommon( StorageClasses, NumStorageClass ) 68 CommonBF( NumStorageClass ) 97 69 }; // StorageClasses 98 70 99 71 enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NumTypeQualifier = 6 }; 100 static const char * QualifiersNames[];101 72 union Qualifiers { 102 73 enum { Mask = ~(Restrict | Lvalue) }; 103 74 unsigned int val; 104 75 struct { 105 bool is _const : 1;106 bool is _restrict : 1;107 bool is _volatile : 1;108 bool is _lvalue : 1;109 bool is _mutex : 1;110 bool is _atomic : 1;76 bool isConst : 1; 77 bool isRestrict : 1; 78 bool isVolatile : 1; 79 bool isLvalue : 1; 80 bool isMutex : 1; 81 bool isAtomic : 1; 111 82 }; 112 83 113 84 Qualifiers() : val( 0 ) {} 114 85 Qualifiers( unsigned int val ) : val( val ) {} 115 // Complex comparisons provide implicit qualifier downcasting, e.g., T downcast to const T. 116 bool operator==( Qualifiers other ) const { return (val & Mask) == (other.val & Mask); } 117 bool operator!=( Qualifiers other ) const { return (val & Mask) != (other.val & Mask); } 86 bool operator==( Qualifiers other ) const { 87 return (val & Mask) == (other.val & Mask); 88 } 89 bool operator!=( Qualifiers other ) const { 90 return (val & Mask) != (other.val & Mask); 91 } 118 92 bool operator<=( Qualifiers other ) const { 119 return is_const <= other.is_const && is_volatile <= other.is_volatile && 120 is_mutex >= other.is_mutex && is_atomic == other.is_atomic; 121 } 122 bool operator<( Qualifiers other ) const { return *this != other && *this <= other; } 123 bool operator>=( Qualifiers other ) const { return ! (*this < other); } 124 bool operator>( Qualifiers other ) const { return *this != other && *this >= other; } 125 BFCommon( Qualifiers, NumTypeQualifier ) 93 return isConst <= other.isConst && isVolatile <= other.isVolatile && 94 isMutex >= other.isMutex && isAtomic == other.isAtomic; 95 } 96 bool operator>=( Qualifiers other ) const { 97 return isConst >= other.isConst && isVolatile >= other.isVolatile && 98 isMutex <= other.isMutex && isAtomic == other.isAtomic; 99 } 100 bool operator<( Qualifiers other ) const { 101 return *this != other && *this <= other; 102 } 103 bool operator>( Qualifiers other ) const { 104 return *this != other && *this >= other; 105 } 106 Qualifiers operator&=( Type::Qualifiers other ) { 107 val &= other.val; return *this; 108 } 109 Qualifiers operator+=( Qualifiers other ) { 110 val |= other.val; return *this; 111 } 112 Qualifiers operator-=( Qualifiers other ) { 113 val &= ~other.val; return *this; 114 } 115 Qualifiers operator+( Qualifiers other ) const { 116 Qualifiers q = other; 117 q += *this; 118 return q; 119 } 120 CommonBF( NumTypeQualifier ) 126 121 }; // Qualifiers 127 122 … … 131 126 132 127 Qualifiers & get_qualifiers() { return tq; } 133 bool get_const() { return tq.is_const; } 134 bool get_volatile() { return tq.is_volatile; } 135 bool get_restrict() { return tq.is_restrict; } 136 bool get_lvalue() { return tq.is_lvalue; } 137 bool get_mutex() { return tq.is_mutex; } 138 bool get_atomic() { return tq.is_atomic; } 139 void set_const( bool newValue ) { tq.is_const = newValue; } 140 void set_volatile( bool newValue ) { tq.is_volatile = newValue; } 141 void set_restrict( bool newValue ) { tq.is_restrict = newValue; } 142 void set_lvalue( bool newValue ) { tq.is_lvalue = newValue; } 143 void set_mutex( bool newValue ) { tq.is_mutex = newValue; } 144 void set_atomic( bool newValue ) { tq.is_atomic = newValue; } 128 bool get_isConst() { return tq.isConst; } 129 bool get_isVolatile() { return tq.isVolatile; } 130 bool get_isRestrict() { return tq.isRestrict; } 131 bool get_isLvalue() { return tq.isLvalue; } 132 bool get_isAtomic() { return tq.isAtomic; } 133 void set_isConst( bool newValue ) { tq.isConst = newValue; } 134 void set_isVolatile( bool newValue ) { tq.isVolatile = newValue; } 135 void set_isRestrict( bool newValue ) { tq.isRestrict = newValue; } 136 void set_isLvalue( bool newValue ) { tq.isLvalue = newValue; } 137 void set_isAtomic( bool newValue ) { tq.isAtomic = newValue; } 145 138 146 139 typedef std::list<TypeDecl *> ForallList; … … 154 147 virtual bool isVoid() const { return size() == 0; } 155 148 virtual Type * getComponent( unsigned i ) { assertf( size() == 1 && i == 0, "Type::getComponent was called with size %d and index %d\n", size(), i ); return this; } 156 157 Type *stripDeclarator();158 149 159 150 virtual bool isComplete() const { return true; } -
src/SynTree/TypeSubstitution.cc
r7c70089 rb32ada31 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : T hu Mar 16 15:54:35 201713 // Update Count : 411 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Apr 26 11:15:29 2016 13 // Update Count : 3 14 14 // 15 15 … … 127 127 subCount++; 128 128 Type *newtype = i->second->clone(); 129 newtype->get_qualifiers() |= inst->get_qualifiers();129 newtype->get_qualifiers() += inst->get_qualifiers(); 130 130 delete inst; 131 131 return newtype; -
src/Tuples/TupleAssignment.cc
r7c70089 rb32ada31 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 17 09:43:03201713 // Update Count : 812 // Last Modified On : Thu Mar 16 08:04:51 2017 13 // Update Count : 7 14 14 // 15 15 … … 200 200 assert( type ); 201 201 type->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic ); 202 type->set_ lvalue( true ); // xxx - might not need this202 type->set_isLvalue( true ); // xxx - might not need this 203 203 expr = new CastExpr( expr, castType ); 204 204 } -
src/Tuples/TupleExpansion.cc
r7c70089 rb32ada31 126 126 /// given a expression representing the member and an expression representing the aggregate, 127 127 /// reconstructs a flattened UntypedMemberExpr with the right precedence 128 Expression * reconstructMemberExpr( Expression * member, Expression * aggr , CodeLocation & loc) {128 Expression * reconstructMemberExpr( Expression * member, Expression * aggr ) { 129 129 if ( UntypedMemberExpr * memberExpr = dynamic_cast< UntypedMemberExpr * >( member ) ) { 130 130 // construct a new UntypedMemberExpr with the correct structure , and recursively 131 131 // expand that member expression. 132 132 MemberTupleExpander expander; 133 UntypedMemberExpr * inner = new UntypedMemberExpr( memberExpr->get_aggregate(), aggr->clone() ); 134 UntypedMemberExpr * newMemberExpr = new UntypedMemberExpr( memberExpr->get_member(), inner ); 135 inner->location = newMemberExpr->location = loc; 133 UntypedMemberExpr * newMemberExpr = new UntypedMemberExpr( memberExpr->get_member(), new UntypedMemberExpr( memberExpr->get_aggregate(), aggr->clone() ) ); 134 136 135 memberExpr->set_member(nullptr); 137 136 memberExpr->set_aggregate(nullptr); … … 140 139 } else { 141 140 // not a member expression, so there is nothing to do but attach and return 142 UntypedMemberExpr * newMemberExpr = new UntypedMemberExpr( member, aggr->clone() ); 143 newMemberExpr->location = loc; 144 return newMemberExpr; 141 return new UntypedMemberExpr( member, aggr->clone() ); 145 142 } 146 143 } … … 155 152 aggr = new UniqueExpr( aggr ); 156 153 for ( Expression *& expr : tupleExpr->get_exprs() ) { 157 expr = reconstructMemberExpr( expr, aggr, memberExpr->location ); 158 expr->location = memberExpr->location; 154 expr = reconstructMemberExpr( expr, aggr ); 159 155 } 160 156 delete aggr; 161 tupleExpr->location = memberExpr->location;162 157 return tupleExpr; 163 158 } else { 164 159 // there may be a tuple expr buried in the aggregate 165 160 // xxx - this is a memory leak 166 UntypedMemberExpr * newMemberExpr = new UntypedMemberExpr( memberExpr->get_member()->clone(), memberExpr->get_aggregate()->acceptMutator( *this ) ); 167 newMemberExpr->location = memberExpr->location; 168 return newMemberExpr; 161 return new UntypedMemberExpr( memberExpr->get_member()->clone(), memberExpr->get_aggregate()->acceptMutator( *this ) ); 169 162 } 170 163 } -
src/tests/.expect/memberCtors-ERR1.txt
r7c70089 rb32ada31 1 memberCtors.c:62error: in void ?{}(struct B *b), field a2 used before being constructed1 error: in void ?{}(struct B *b), field a2 used before being constructed 2 2 make: *** [memberCtors-ERR1] Error 1
Note:
See TracChangeset
for help on using the changeset viewer.