Changeset add7117
- Timestamp:
- Sep 10, 2016, 11:08:47 AM (9 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:
- 5af62f1
- Parents:
- f5e81d1 (diff), 03e3117 (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:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/InitTweak/FixInit.cc ¶
rf5e81d1 radd7117 33 33 #include "SymTab/Autogen.h" 34 34 #include "GenPoly/PolyMutator.h" 35 #include "GenPoly/DeclMutator.h" 35 36 #include "SynTree/AddStmtVisitor.h" 36 37 #include "CodeGen/GenType.h" // for warnings … … 216 217 SymTab::Indexer & indexer; 217 218 }; 219 220 class FixCtorExprs : public GenPoly::DeclMutator { 221 public: 222 /// expands ConstructorExpr nodes into comma expressions, using a temporary for the first argument 223 static void fix( std::list< Declaration * > & translationUnit ); 224 225 virtual Expression * mutate( ConstructorExpr * ctorExpr ); 226 }; 218 227 } // namespace 219 228 … … 221 230 // fixes ConstructorInit for global variables. should happen before fixInitializers. 222 231 InitTweak::fixGlobalInit( translationUnit, filename, inLibrary ); 232 223 233 224 234 InsertImplicitCalls::insert( translationUnit ); … … 231 241 232 242 GenStructMemberCalls::generate( translationUnit ); 243 // xxx - ctor expansion currently has to be after FixCopyCtors, because there is currently a 244 // hack in the way untyped assignments are generated, where the first argument cannot have 245 // its address taken because of the way codegeneration handles UntypedExpr vs. ApplicationExpr. 246 // Thus such assignment exprs must never pushed through expression resolution (and thus should 247 // not go through the FixCopyCtors pass), otherwise they will fail -- guaranteed. 248 // Also needs to happen after GenStructMemberCalls, since otherwise member constructors exprs 249 // don't look right, and a member can be constructed more than once. 250 FixCtorExprs::fix( translationUnit ); 233 251 } 234 252 … … 283 301 throw warner.errors; 284 302 } 303 } 304 305 void FixCtorExprs::fix( std::list< Declaration * > & translationUnit ) { 306 FixCtorExprs fixer; 307 fixer.mutateDeclarationList( translationUnit ); 285 308 } 286 309 … … 480 503 retExpr = deref; 481 504 } // if 482 // xxx - might need to set env on retExpr... 483 // retExpr->set_env( env->clone() ); 505 retExpr->set_env( env->clone() ); 484 506 return retExpr; 485 507 } else { … … 914 936 return safe_dynamic_cast< ApplicationExpr * >( ResolvExpr::findVoidExpression( untypedExpr, indexer ) ); 915 937 } 938 939 Expression * FixCtorExprs::mutate( ConstructorExpr * ctorExpr ) { 940 static UniqueName tempNamer( "_tmp_ctor_expr" ); 941 assert( ctorExpr->get_results().size() == 1 ); 942 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, ctorExpr->get_results().front()->clone(), nullptr ); 943 addDeclaration( tmp ); 944 945 ApplicationExpr * callExpr = safe_dynamic_cast< ApplicationExpr * > ( ctorExpr->get_callExpr() ); 946 TypeSubstitution * env = ctorExpr->get_env(); 947 ctorExpr->set_callExpr( nullptr ); 948 ctorExpr->set_env( nullptr ); 949 950 Expression *& firstArg = callExpr->get_args().front(); 951 UntypedExpr * assign = new UntypedExpr( new NameExpr( "?=?" ) ); 952 assign->get_args().push_back( new VariableExpr( tmp ) ); 953 assign->get_args().push_back( firstArg ); 954 cloneAll( ctorExpr->get_results(), assign->get_results() ); 955 firstArg = assign; 956 957 CommaExpr * commaExpr = new CommaExpr( callExpr, new VariableExpr( tmp ) ); 958 commaExpr->set_env( env ); 959 delete ctorExpr; 960 return commaExpr; 961 } 916 962 } // namespace 917 963 } // namespace InitTweak -
TabularUnified src/InitTweak/InitTweak.cc ¶
rf5e81d1 radd7117 358 358 template<typename CallExpr> 359 359 Expression *& callArg( CallExpr * callExpr, unsigned int pos ) { 360 if ( pos >= callExpr->get_args().size() ) assert ( false &&"asking for argument that doesn't exist. Return NULL/throw exception?" );360 if ( pos >= callExpr->get_args().size() ) assertf( false, "asking for argument that doesn't exist. Return NULL/throw exception?" ); 361 361 for ( Expression *& arg : callExpr->get_args() ) { 362 362 if ( pos == 0 ) return arg; … … 373 373 return callArg( untypedExpr, pos ); 374 374 } else { 375 assert ( false &&"Unexpected expression type passed to getCallArg" );375 assertf( false, "Unexpected expression type passed to getCallArg" ); 376 376 } 377 377 } … … 388 388 return memberExpr->get_member()->get_name(); 389 389 } else { 390 assert ( false &&"Unexpected expression type being called as a function in call expression" );390 assertf( false, "Unexpected expression type being called as a function in call expression" ); 391 391 } 392 392 } … … 400 400 } else { 401 401 std::cerr << expr << std::endl; 402 assert ( false &&"Unexpected expression type passed to getFunctionName" );402 assertf( false, "Unexpected expression type passed to getFunctionName" ); 403 403 } 404 404 } -
TabularUnified src/Parser/DeclarationNode.cc ¶
rf5e81d1 radd7117 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 29 22:30:56201613 // Update Count : 32712 // Last Modified On : Fri Sep 9 23:21:47 2016 13 // Update Count : 402 14 14 // 15 15 … … 43 43 extern LinkageSpec::Spec linkage; // defined in parser.yy 44 44 45 DeclarationNode::DeclarationNode() 46 : type( 0 ) 47 , storageClass( NoStorageClass ) 48 , isInline( false ) 49 , isNoreturn( false ) 50 , bitfieldWidth( 0 ) 51 , initializer( 0 ) 52 , hasEllipsis( false ) 53 , linkage( ::linkage ) 54 , extension( false ) 55 , error() { 45 DeclarationNode::DeclarationNode() : 46 type( 0 ), 47 storageClass( NoStorageClass ), 48 isInline( false ), 49 isNoreturn( false ), 50 bitfieldWidth( 0 ), 51 initializer( 0 ), 52 hasEllipsis( false ), 53 linkage( ::linkage ), 54 extension( false ) { 55 variable.tyClass = DeclarationNode::Type; 56 variable.assertions = nullptr; 57 56 58 attr.expr = nullptr; 57 59 attr.type = nullptr; 58 59 variable.tyClass = DeclarationNode::Type;60 variable.assertions = nullptr;61 60 } 62 61 … … 393 392 394 393 if ( (qsrc & qdst).any() ) { // common bits between qualifier masks ? 395 error = "duplicate qualifier "; 396 int j = 0; // separator detector 397 for ( int i = 0; i < DeclarationNode::NoOfQualifier; i += 1 ) { 398 if ( qsrc[i] & qdst[i] ) { // find specific qualifiers in common 399 if ( j > 0 ) error += ", "; 400 error += DeclarationNode::qualifierName[i]; 401 j += 1; 394 for ( int i = 0; i < NoOfQualifier; i += 1 ) { // find common qualifiers 395 if ( qsrc[i] & qdst[i] ) { 396 error += string(error.empty() ? "" : ", ") + "duplicate " + DeclarationNode::qualifierName[i]; 402 397 } // if 403 398 } // for 404 error += " in declaration of ";405 399 } // if 406 400 } // DeclarationNode::checkQualifiers … … 442 436 storageClass = q->storageClass; 443 437 } else if ( q->storageClass != NoStorageClass ) { 444 q->error = "invalid combination of storage classes in declaration of "; 445 } // if 446 if ( error.empty() ) error = q->error; 447 return this; 448 } 438 if ( storageClass == q->storageClass ) { 439 q->error += string( "duplicate " ) + storageName[ storageClass ]; 440 } else { // can only have one storage class 441 q->error += string( "multiple " ) + storageName[ storageClass ] + " & " + storageName[ q->storageClass ]; 442 } // if 443 } // if 444 if ( ! q->error.empty() ) { 445 error += (! error.empty() ? ", " : "") + q->error; 446 } // if 447 return this; 448 } // DeclarationNode::copyStorageClasses 449 449 450 450 static void addTypeToType( TypeData *&src, TypeData *&dst ) { … … 908 908 909 909 Declaration *DeclarationNode::build() const { 910 if ( ! error.empty() ) throw SemanticError( error , this );910 if ( ! error.empty() ) throw SemanticError( error + " in declaration of ", this ); 911 911 if ( type ) { 912 912 if ( type->kind == TypeData::Variable ) { … … 922 922 return (new ObjectDecl( name, storageClass, linkage, maybeBuild< Expression >( bitfieldWidth ), 0, maybeBuild< Initializer >( initializer ) ))->set_extension( extension ); 923 923 } // if 924 throw SemanticError( "invalid function specifier in declaration of", this );924 throw SemanticError( "invalid function specifier ", this ); 925 925 } 926 926 … … 971 971 } 972 972 973 // DeclarationNode::StorageClass DeclarationNode::buildStorageClass() const {974 // DeclarationNode::StorageClass ret = DeclarationNode::NoStorageClass;975 // for ( std::list< DeclarationNode::StorageClass >::const_iterator i = storageClasses.begin(); i != storageClasses.end(); ++i ) {976 // if ( *i == DeclarationNode::Inline || *i == DeclarationNode::Noreturn ) continue; // ignore function specifiers977 // if ( ret != DeclarationNode::NoStorageClass ) { // already have a valid storage class ?978 // throw SemanticError( "invalid combination of storage classes in declaration of ", this );979 // } // if980 // ret = *i;981 // } // for982 // return ret;983 // }984 985 // bool DeclarationNode::buildFuncSpecifier( DeclarationNode::StorageClass key ) const {986 // std::list< DeclarationNode::StorageClass >::const_iterator first = std::find( storageClasses.begin(), storageClasses.end(), key );987 // if ( first == storageClasses.end() ) return false; // not found988 // first = std::find( ++first, storageClasses.end(), key ); // found989 // if ( first == storageClasses.end() ) return true; // not found again990 // throw SemanticError( "duplicate function specifier in declaration of ", this );991 // }992 993 973 // Local Variables: // 994 974 // tab-width: 4 // -
TabularUnified src/Parser/ParseNode.h ¶
rf5e81d1 radd7117 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 29 21:45:43201613 // Update Count : 58 312 // Last Modified On : Thu Sep 8 21:58:06 2016 13 // Update Count : 587 14 14 // 15 15 … … 290 290 // bool buildFuncSpecifier( StorageClass key ) const; 291 291 292 struct Enumeration_t {293 std::string name;294 DeclarationNode * constants;295 };296 Enumeration_t enumeration;297 298 292 struct Variable_t { 299 293 DeclarationNode::TypeClass tyClass; … … 408 402 if ( result ) { 409 403 *out++ = result; 410 } else {411 404 } // if 412 405 } catch( SemanticError &e ) { -
TabularUnified src/Parser/TypeData.h ¶
rf5e81d1 radd7117 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 29 22:31:52201613 // Update Count : 11 012 // Last Modified On : Fri Sep 9 23:20:55 2016 13 // Update Count : 117 14 14 // 15 15 … … 96 96 Array_t array; 97 97 Enumeration_t enumeration; 98 // Variable_t variable; 98 99 Function_t function; 99 100 Symbolic_t symbolic; 100 101 DeclarationNode * tuple; 101 102 ExpressionNode * typeexpr; 102 // Attr_t attr;103 // Attr_t attr; 103 104 // DeclarationNode::BuiltinType builtin; 104 105 -
TabularUnified src/Parser/parser.cc ¶
rf5e81d1 radd7117 5125 5125 { 5126 5126 Token fn; 5127 fn.str = new std::string( "?{}" ); // location undefined 5128 (yyval.en) = new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( (yyvsp[(1) - (4)].en) )->set_last( (yyvsp[(3) - (4)].en) ) ) );5127 fn.str = new std::string( "?{}" ); // location undefined - use location of '{'? 5128 (yyval.en) = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( (yyvsp[(1) - (4)].en) )->set_last( (yyvsp[(3) - (4)].en) ) ) ) ); 5129 5129 } 5130 5130 break; -
TabularUnified src/Parser/parser.yy ¶
rf5e81d1 radd7117 391 391 { 392 392 Token fn; 393 fn.str = new std::string( "?{}" ); // location undefined 394 $$ = new ExpressionNode( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3) ) );393 fn.str = new std::string( "?{}" ); // location undefined - use location of '{'? 394 $$ = new ExpressionNode( new ConstructorExpr( build_func( new ExpressionNode( build_varref( fn ) ), (ExpressionNode *)( $1 )->set_last( $3 ) ) ) ); 395 395 } 396 396 ; -
TabularUnified src/ResolvExpr/AlternativeFinder.cc ¶
rf5e81d1 radd7117 209 209 } 210 210 211 void AlternativeFinder::find( Expression *expr, bool adjust ) {211 void AlternativeFinder::find( Expression *expr, bool adjust, bool prune ) { 212 212 expr->accept( *this ); 213 213 if ( alternatives.empty() ) { … … 219 219 } 220 220 } 221 PRINT( 222 std::cerr << "alternatives before prune:" << std::endl; 223 printAlts( alternatives, std::cerr ); 224 ) 225 AltList::iterator oldBegin = alternatives.begin(); 226 pruneAlternatives( alternatives.begin(), alternatives.end(), front_inserter( alternatives ), indexer ); 227 if ( alternatives.begin() == oldBegin ) { 228 std::ostringstream stream; 229 stream << "Can't choose between alternatives for expression "; 230 expr->print( stream ); 231 stream << "Alternatives are:"; 232 AltList winners; 233 findMinCost( alternatives.begin(), alternatives.end(), back_inserter( winners ) ); 234 printAlts( winners, stream, 8 ); 235 throw SemanticError( stream.str() ); 236 } 237 alternatives.erase( oldBegin, alternatives.end() ); 238 PRINT( 239 std::cerr << "there are " << alternatives.size() << " alternatives after elimination" << std::endl; 240 ) 221 if ( prune ) { 222 PRINT( 223 std::cerr << "alternatives before prune:" << std::endl; 224 printAlts( alternatives, std::cerr ); 225 ) 226 AltList::iterator oldBegin = alternatives.begin(); 227 pruneAlternatives( alternatives.begin(), alternatives.end(), front_inserter( alternatives ), indexer ); 228 if ( alternatives.begin() == oldBegin ) { 229 std::ostringstream stream; 230 stream << "Can't choose between alternatives for expression "; 231 expr->print( stream ); 232 stream << "Alternatives are:"; 233 AltList winners; 234 findMinCost( alternatives.begin(), alternatives.end(), back_inserter( winners ) ); 235 printAlts( winners, stream, 8 ); 236 throw SemanticError( stream.str() ); 237 } 238 alternatives.erase( oldBegin, alternatives.end() ); 239 PRINT( 240 std::cerr << "there are " << alternatives.size() << " alternatives after elimination" << std::endl; 241 ) 242 } 241 243 242 244 // Central location to handle gcc extension keyword for all expression types. … … 246 248 } 247 249 248 void AlternativeFinder::findWithAdjustment( Expression *expr ) {249 find( expr, true );250 void AlternativeFinder::findWithAdjustment( Expression *expr, bool prune ) { 251 find( expr, true, prune ); 250 252 } 251 253 252 254 template< typename StructOrUnionType > 253 void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, Expression * member ) {255 void AlternativeFinder::addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ) { 254 256 NameExpr * nameExpr = safe_dynamic_cast< NameExpr * >( member ); 255 257 const std::string & name = nameExpr->get_name(); 256 257 258 std::list< Declaration* > members; 258 259 aggInst->lookup( name, members ); … … 813 814 if ( agg->expr->get_results().size() == 1 ) { 814 815 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_results().front() ) ) { 815 addAggMembers( structInst, agg->expr, agg->cost, memberExpr->get_member() );816 addAggMembers( structInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 816 817 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( agg->expr->get_results().front() ) ) { 817 addAggMembers( unionInst, agg->expr, agg->cost, memberExpr->get_member() );818 addAggMembers( unionInst, agg->expr, agg->cost, agg->env, memberExpr->get_member() ); 818 819 } // if 819 820 } // if … … 843 844 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( (*i)->get_type() ) ) { 844 845 NameExpr nameExpr( "" ); 845 addAggMembers( structInst, &newExpr, Cost( 0, 0, 1 ), &nameExpr );846 addAggMembers( structInst, &newExpr, Cost( 0, 0, 1 ), env, &nameExpr ); 846 847 } else if ( UnionInstType *unionInst = dynamic_cast< UnionInstType* >( (*i)->get_type() ) ) { 847 848 NameExpr nameExpr( "" ); 848 addAggMembers( unionInst, &newExpr, Cost( 0, 0, 1 ), &nameExpr );849 addAggMembers( unionInst, &newExpr, Cost( 0, 0, 1 ), env, &nameExpr ); 849 850 } // if 850 851 } // for … … 1067 1068 alternatives.push_back( Alternative( impCpCtorExpr->clone(), env, Cost::zero ) ); 1068 1069 } 1070 1071 void AlternativeFinder::visit( ConstructorExpr * ctorExpr ) { 1072 AlternativeFinder finder( indexer, env ); 1073 // don't prune here, since it's guaranteed all alternatives will have the same type 1074 // (giving the alternatives different types is half of the point of ConstructorExpr nodes) 1075 finder.findWithAdjustment( ctorExpr->get_callExpr(), false ); 1076 for ( Alternative & alt : finder.alternatives ) { 1077 alternatives.push_back( Alternative( new ConstructorExpr( alt.expr->clone() ), alt.env, alt.cost ) ); 1078 } 1079 } 1069 1080 } // namespace ResolvExpr 1070 1081 -
TabularUnified src/ResolvExpr/AlternativeFinder.h ¶
rf5e81d1 radd7117 29 29 public: 30 30 AlternativeFinder( const SymTab::Indexer &indexer, const TypeEnvironment &env ); 31 void find( Expression *expr, bool adjust = false );31 void find( Expression *expr, bool adjust = false, bool prune = true ); 32 32 /// Calls find with the adjust flag set; adjustment turns array and function types into equivalent pointer types 33 void findWithAdjustment( Expression *expr );33 void findWithAdjustment( Expression *expr, bool prune = true ); 34 34 AltList &get_alternatives() { return alternatives; } 35 35 … … 66 66 virtual void visit( TupleExpr *tupleExpr ); 67 67 virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr ); 68 virtual void visit( ConstructorExpr * ctorExpr ); 68 69 public: // xxx - temporary hack - should make Tuples::TupleAssignment a friend 69 70 /// Runs a new alternative finder on each element in [begin, end) … … 74 75 private: 75 76 /// Adds alternatives for member expressions, given the aggregate, conversion cost for that aggregate, and name of the member 76 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, Expression * member );77 template< typename StructOrUnionType > void addAggMembers( StructOrUnionType *aggInst, Expression *expr, const Cost &newCost, const TypeEnvironment & env, Expression * member ); 77 78 /// Adds alternatives for offsetof expressions, given the base type and name of the member 78 79 template< typename StructOrUnionType > void addOffsetof( StructOrUnionType *aggInst, const std::string &name ); -
TabularUnified src/SymTab/Validate.cc ¶
rf5e81d1 radd7117 60 60 #include "ResolvExpr/typeops.h" 61 61 #include <algorithm> 62 #include "InitTweak/InitTweak.h" 62 63 63 64 #define debugPrint( x ) if ( doDebug ) { std::cout << x; } … … 171 172 }; 172 173 173 class VerifyCtorDtor : public Visitor {174 class VerifyCtorDtorAssign : public Visitor { 174 175 public: 175 /// ensure that constructors and destructorshave at least one176 /// parameter, the first of which must be a pointer, and no176 /// ensure that constructors, destructors, and assignment have at least one 177 /// parameter, the first of which must be a pointer, and that ctor/dtors have no 177 178 /// return values. 178 179 static void verify( std::list< Declaration * > &translationUnit ); … … 202 203 compoundliteral.mutateDeclarationList( translationUnit ); 203 204 acceptAll( translationUnit, pass3 ); 204 VerifyCtorDtor ::verify( translationUnit );205 VerifyCtorDtorAssign::verify( translationUnit ); 205 206 } 206 207 … … 687 688 } 688 689 689 void VerifyCtorDtor ::verify( std::list< Declaration * > & translationUnit ) {690 VerifyCtorDtor verifier;690 void VerifyCtorDtorAssign::verify( std::list< Declaration * > & translationUnit ) { 691 VerifyCtorDtorAssign verifier; 691 692 acceptAll( translationUnit, verifier ); 692 693 } 693 694 694 void VerifyCtorDtor ::visit( FunctionDecl * funcDecl ) {695 void VerifyCtorDtorAssign::visit( FunctionDecl * funcDecl ) { 695 696 FunctionType * funcType = funcDecl->get_functionType(); 696 697 std::list< DeclarationWithType * > &returnVals = funcType->get_returnVals(); 697 698 std::list< DeclarationWithType * > ¶ms = funcType->get_parameters(); 698 699 699 if ( funcDecl->get_name() == "?{}" || funcDecl->get_name() == "^?{}") {700 if ( InitTweak::isCtorDtorAssign( funcDecl->get_name() ) ) { 700 701 if ( params.size() == 0 ) { 701 throw SemanticError( "Constructors and destructors require at least one parameter ", funcDecl );702 throw SemanticError( "Constructors, destructors, and assignment functions require at least one parameter ", funcDecl ); 702 703 } 703 704 if ( ! dynamic_cast< PointerType * >( params.front()->get_type() ) ) { 704 throw SemanticError( "First parameter of a constructor or destructormust be a pointer ", funcDecl );705 throw SemanticError( "First parameter of a constructor, destructor, or assignment function must be a pointer ", funcDecl ); 705 706 } 706 if ( returnVals.size() != 0 ) {707 if ( InitTweak::isCtorDtor( funcDecl->get_name() ) && returnVals.size() != 0 ) { 707 708 throw SemanticError( "Constructors and destructors cannot have explicit return values ", funcDecl ); 708 709 } -
TabularUnified src/SynTree/Expression.cc ¶
rf5e81d1 radd7117 28 28 #include "TypeSubstitution.h" 29 29 #include "Common/utility.h" 30 #include "InitTweak/InitTweak.h" 30 31 31 32 … … 496 497 497 498 void ImplicitCopyCtorExpr::print( std::ostream &os, int indent ) const { 498 os << std::string( indent, ' ' ) <<"Implicit Copy Constructor Expression: " << std::endl;499 os << "Implicit Copy Constructor Expression: " << std::endl; 499 500 assert( callExpr ); 500 501 callExpr->print( os, indent + 2 ); … … 506 507 } 507 508 509 510 ConstructorExpr::ConstructorExpr( Expression * callExpr ) : callExpr( callExpr ) { 511 // allow resolver to type a constructor used as an expression as if it has the same type as its first argument 512 assert( callExpr ); 513 Expression * arg = InitTweak::getCallArg( callExpr, 0 ); 514 assert( arg ); 515 cloneAll( arg->get_results(), results ); 516 } 517 518 ConstructorExpr::ConstructorExpr( const ConstructorExpr & other ) : Expression( other ), callExpr( maybeClone( other.callExpr ) ) { 519 } 520 521 ConstructorExpr::~ConstructorExpr() { 522 delete callExpr; 523 } 524 525 void ConstructorExpr::print( std::ostream &os, int indent ) const { 526 os << "Constructor Expression: " << std::endl; 527 assert( callExpr ); 528 os << std::string( indent+2, ' ' ); 529 callExpr->print( os, indent + 2 ); 530 Expression::print( os, indent ); 531 } 532 533 534 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) { 535 add_result( type->clone() ); 536 } 537 538 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {} 539 540 CompoundLiteralExpr::~CompoundLiteralExpr() { 541 delete initializer; 542 delete type; 543 } 544 545 void CompoundLiteralExpr::print( std::ostream &os, int indent ) const { 546 os << "Compound Literal Expression: " << std::endl; 547 if ( type ) type->print( os, indent + 2 ); 548 if ( initializer ) initializer->print( os, indent + 2 ); 549 } 550 508 551 UntypedValofExpr::UntypedValofExpr( const UntypedValofExpr & other ) : Expression( other ), body ( maybeClone( other.body ) ) {} 509 552 … … 514 557 if ( get_body() != 0 ) 515 558 get_body()->print( os, indent + 2 ); 516 }517 518 519 CompoundLiteralExpr::CompoundLiteralExpr( Type * type, Initializer * initializer ) : type( type ), initializer( initializer ) {520 add_result( type->clone() );521 }522 523 CompoundLiteralExpr::CompoundLiteralExpr( const CompoundLiteralExpr &other ) : Expression( other ), type( maybeClone( other.type ) ), initializer( maybeClone( other.initializer ) ) {}524 525 CompoundLiteralExpr::~CompoundLiteralExpr() {526 delete initializer;527 delete type;528 }529 530 void CompoundLiteralExpr::print( std::ostream &os, int indent ) const {531 os << "Compound Literal Expression: " << std::endl;532 if ( type ) type->print( os, indent + 2 );533 if ( initializer ) initializer->print( os, indent + 2 );534 559 } 535 560 -
TabularUnified src/SynTree/Expression.h ¶
rf5e81d1 radd7117 595 595 }; 596 596 597 /// ConstructorExpr represents the use of a constructor in an expression context, e.g. int * x = malloc() { 5 }; 598 class ConstructorExpr : public Expression { 599 public: 600 ConstructorExpr( Expression * callExpr ); 601 ConstructorExpr( const ConstructorExpr & other ); 602 ~ConstructorExpr(); 603 604 Expression *get_callExpr() const { return callExpr; } 605 void set_callExpr( Expression *newValue ) { callExpr = newValue; } 606 607 virtual ConstructorExpr *clone() const { return new ConstructorExpr( *this ); } 608 virtual void accept( Visitor &v ) { v.visit( this ); } 609 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 610 virtual void print( std::ostream &os, int indent = 0 ) const; 611 private: 612 Expression * callExpr; 613 }; 614 615 /// CompoundLiteralExpr represents a C99 'compound literal' 616 class CompoundLiteralExpr : public Expression { 617 public: 618 CompoundLiteralExpr( Type * type, Initializer * initializer ); 619 CompoundLiteralExpr( const CompoundLiteralExpr &other ); 620 virtual ~CompoundLiteralExpr(); 621 622 Type * get_type() const { return type; } 623 void set_type( Type * t ) { type = t; } 624 625 Initializer * get_initializer() const { return initializer; } 626 void set_initializer( Initializer * i ) { initializer = i; } 627 628 virtual CompoundLiteralExpr *clone() const { return new CompoundLiteralExpr( *this ); } 629 virtual void accept( Visitor &v ) { v.visit( this ); } 630 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 631 virtual void print( std::ostream &os, int indent = 0 ) const; 632 private: 633 Type * type; 634 Initializer * initializer; 635 }; 636 597 637 /// ValofExpr represents a GCC 'lambda expression' 598 638 class UntypedValofExpr : public Expression { … … 613 653 }; 614 654 615 /// CompoundLiteralExpr represents a C99 'compound literal' 616 class CompoundLiteralExpr : public Expression { 617 public: 618 CompoundLiteralExpr( Type * type, Initializer * initializer ); 619 CompoundLiteralExpr( const CompoundLiteralExpr &other ); 620 virtual ~CompoundLiteralExpr(); 621 622 Type * get_type() const { return type; } 623 void set_type( Type * t ) { type = t; } 624 625 Initializer * get_initializer() const { return initializer; } 626 void set_initializer( Initializer * i ) { initializer = i; } 627 628 virtual CompoundLiteralExpr *clone() const { return new CompoundLiteralExpr( *this ); } 629 virtual void accept( Visitor &v ) { v.visit( this ); } 630 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } 631 virtual void print( std::ostream &os, int indent = 0 ) const; 632 private: 633 Type * type; 634 Initializer * initializer; 635 }; 636 655 /// RangeExpr represents a range e.g. '3 ... 5' or '1~10' 637 656 class RangeExpr : public Expression { 638 657 public: -
TabularUnified src/SynTree/Mutator.cc ¶
rf5e81d1 radd7117 340 340 } 341 341 342 Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) { 343 mutateAll( valofExpr->get_results(), *this ); 344 return valofExpr; 342 Expression* Mutator::mutate( ConstructorExpr *ctorExpr ) { 343 mutateAll( ctorExpr->get_results(), *this ); 344 ctorExpr->set_callExpr( maybeMutate( ctorExpr->get_callExpr(), *this ) ); 345 return ctorExpr; 345 346 } 346 347 … … 350 351 compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) ); 351 352 return compLitExpr; 353 } 354 355 Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) { 356 mutateAll( valofExpr->get_results(), *this ); 357 return valofExpr; 352 358 } 353 359 -
TabularUnified src/SynTree/Mutator.h ¶
rf5e81d1 radd7117 76 76 virtual Expression* mutate( AsmExpr *asmExpr ); 77 77 virtual Expression* mutate( ImplicitCopyCtorExpr *impCpCtorExpr ); 78 virtual Expression* mutate( ConstructorExpr *ctorExpr ); 79 virtual Expression* mutate( CompoundLiteralExpr *compLitExpr ); 78 80 virtual Expression* mutate( UntypedValofExpr *valofExpr ); 79 virtual Expression* mutate( CompoundLiteralExpr *compLitExpr );80 81 virtual Expression* mutate( RangeExpr *rangeExpr ); 81 82 virtual Expression* mutate( TupleIndexExpr *tupleExpr ); -
TabularUnified src/SynTree/SynTree.h ¶
rf5e81d1 radd7117 81 81 class AsmExpr; 82 82 class ImplicitCopyCtorExpr; 83 class ConstructorExpr; 84 class CompoundLiteralExpr; 83 85 class UntypedValofExpr; 84 class CompoundLiteralExpr;85 86 class RangeExpr; 86 87 class TupleIndexExpr; -
TabularUnified src/SynTree/Visitor.cc ¶
rf5e81d1 radd7117 288 288 } 289 289 290 void Visitor::visit( UntypedValofExpr *valofExpr ) {291 acceptAll( valofExpr->get_results(), *this );292 maybeAccept( valofExpr->get_body(), *this );290 void Visitor::visit( ConstructorExpr * ctorExpr ) { 291 acceptAll( ctorExpr->get_results(), *this ); 292 maybeAccept( ctorExpr->get_callExpr(), *this ); 293 293 } 294 294 … … 297 297 maybeAccept( compLitExpr->get_type(), *this ); 298 298 maybeAccept( compLitExpr->get_initializer(), *this ); 299 } 300 301 void Visitor::visit( UntypedValofExpr *valofExpr ) { 302 acceptAll( valofExpr->get_results(), *this ); 303 maybeAccept( valofExpr->get_body(), *this ); 299 304 } 300 305 -
TabularUnified src/SynTree/Visitor.h ¶
rf5e81d1 radd7117 76 76 virtual void visit( AsmExpr *asmExpr ); 77 77 virtual void visit( ImplicitCopyCtorExpr *impCpCtorExpr ); 78 virtual void visit( ConstructorExpr * ctorExpr ); 79 virtual void visit( CompoundLiteralExpr *compLitExpr ); 78 80 virtual void visit( UntypedValofExpr *valofExpr ); 79 virtual void visit( CompoundLiteralExpr *compLitExpr );80 81 virtual void visit( RangeExpr *rangeExpr ); 81 82 virtual void visit( TupleIndexExpr *tupleExpr ); -
TabularUnified src/include/assert.h ¶
rf5e81d1 radd7117 22 22 #define assertf(expr, fmt, ...) ((expr) ? static_cast<void>(0) : __assert_fail_f(__VSTRINGIFY__(expr), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, ## __VA_ARGS__ )) 23 23 24 void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) ;24 void __assert_fail_f( const char *assertion, const char *file, unsigned int line, const char *function, const char *fmt, ... ) __attribute__((noreturn)); 25 25 26 26 template<typename T, typename U> -
TabularUnified src/libcfa/prelude.cf ¶
rf5e81d1 radd7117 636 636 637 637 // default ctor 638 void ?{}( _Bool * ) , ?{}( volatile _Bool * );639 void ?{}( char * ) , ?{}( volatile char * );640 void ?{}( unsigned char * ) , ?{}( volatile unsigned char * );641 void ?{}( char signed * ) , ?{}( volatile char signed * );642 void ?{}( int short * ) , ?{}( volatile int short * );643 void ?{}( int short unsigned * ) , ?{}( volatile int short unsigned * );644 void ?{}( signed int * ) , ?{}( volatile signed int * );645 void ?{}( unsigned int * ) , ?{}( volatile unsigned int * );646 void ?{}( signed long int * ) , ?{}( volatile signed long int * );647 void ?{}( unsigned long int * ) , ?{}( volatile unsigned long int * );648 void ?{}( signed long long int * ) , ?{}( volatile signed long long int * );649 void ?{}( unsigned long long int * ) , ?{}( volatile unsigned long long int * );650 void ?{}( float * ) , ?{}( volatile float * );651 void ?{}( double * ) , ?{}( volatile double * );652 void ?{}( long double * ) , ?{}( volatile long double * );653 void ?{}( float _Complex * ) , ?{}( volatile float _Complex * );654 void ?{}( double _Complex * ) , ?{}( volatile double _Complex * );655 void ?{}( long double _Complex * ) , ?{}( volatile long double _Complex * );638 void ?{}( _Bool * ); 639 void ?{}( char * ); 640 void ?{}( unsigned char * ); 641 void ?{}( char signed * ); 642 void ?{}( int short * ); 643 void ?{}( int short unsigned * ); 644 void ?{}( signed int * ); 645 void ?{}( unsigned int * ); 646 void ?{}( signed long int * ); 647 void ?{}( unsigned long int * ); 648 void ?{}( signed long long int * ); 649 void ?{}( unsigned long long int * ); 650 void ?{}( float * ); 651 void ?{}( double * ); 652 void ?{}( long double * ); 653 void ?{}( float _Complex * ); 654 void ?{}( double _Complex * ); 655 void ?{}( long double _Complex * ); 656 656 657 657 // copy ctor 658 void ?{}( _Bool *, _Bool ) , ?{}( volatile _Bool *, _Bool );659 void ?{}( char *, char ) , ?{}( volatile char *, char );660 void ?{}( unsigned char *, unsigned char ) , ?{}( volatile unsigned char *, unsigned char );661 void ?{}( char signed *, char signed ) , ?{}( volatile char signed *, char signed );662 void ?{}( int short *, int short ) , ?{}( volatile int short *, int short );663 void ?{}( int short unsigned *, int short unsigned ) , ?{}( volatile int short unsigned *, int short unsigned );664 void ?{}( signed int *, signed int) , ?{}( volatile signed int *, signed int );665 void ?{}( unsigned int *, unsigned int) , ?{}( volatile unsigned int *, unsigned int );666 void ?{}( signed long int *, signed long int) , ?{}( volatile signed long int *, signed long int );667 void ?{}( unsigned long int *, unsigned long int) , ?{}( volatile unsigned long int *, unsigned long int );668 void ?{}( signed long long int *, signed long long int) , ?{}( volatile signed long long int *, signed long long int );669 void ?{}( unsigned long long int *, unsigned long long int) , ?{}( volatile unsigned long long int *, unsigned long long int );670 void ?{}( float *, float) , ?{}( volatile float *, float );671 void ?{}( double *, double) , ?{}( volatile double *, double );672 void ?{}( long double *, long double) , ?{}( volatile long double *, long double );673 void ?{}( float _Complex *, float _Complex) , ?{}( volatile float _Complex *, float _Complex );674 void ?{}( double _Complex *, double _Complex) , ?{}( volatile double _Complex *, double _Complex );675 void ?{}( long double _Complex *, long double _Complex) , ?{}( volatile long double _Complex *, long double _Complex );658 void ?{}( _Bool *, _Bool ); 659 void ?{}( char *, char ); 660 void ?{}( unsigned char *, unsigned char ); 661 void ?{}( char signed *, char signed ); 662 void ?{}( int short *, int short ); 663 void ?{}( int short unsigned *, int short unsigned ); 664 void ?{}( signed int *, signed int); 665 void ?{}( unsigned int *, unsigned int); 666 void ?{}( signed long int *, signed long int); 667 void ?{}( unsigned long int *, unsigned long int); 668 void ?{}( signed long long int *, signed long long int); 669 void ?{}( unsigned long long int *, unsigned long long int); 670 void ?{}( float *, float); 671 void ?{}( double *, double); 672 void ?{}( long double *, long double); 673 void ?{}( float _Complex *, float _Complex); 674 void ?{}( double _Complex *, double _Complex); 675 void ?{}( long double _Complex *, long double _Complex); 676 676 677 677 // dtor 678 void ^?{}( _Bool * ) , ^?{}( volatile _Bool * );679 void ^?{}( char * ) , ^?{}( volatile char * );680 void ^?{}( char unsigned * ) , ^?{}( volatile char unsigned * );681 void ^?{}( char signed * ) , ^?{}( volatile char signed * );682 void ^?{}( int short * ) , ^?{}( volatile int short * );683 void ^?{}( int short unsigned * ) , ^?{}( volatile int short unsigned * );684 void ^?{}( signed int * ) , ^?{}( volatile signed int * );685 void ^?{}( unsigned int * ) , ^?{}( volatile unsigned int * );686 void ^?{}( signed long int * ) , ^?{}( volatile signed long int * );687 void ^?{}( unsigned long int * ) , ^?{}( volatile unsigned long int * );688 void ^?{}( signed long long int * ) , ^?{}( volatile signed long long int * );689 void ^?{}( unsigned long long int * ) , ^?{}( volatile unsigned long long int * );690 void ^?{}( float * ) , ^?{}( volatile float * );691 void ^?{}( double * ) , ^?{}( volatile double * );692 void ^?{}( long double * ) , ^?{}( volatile long double * );693 void ^?{}( float _Complex * ) , ^?{}( volatile float _Complex * );694 void ^?{}( double _Complex * ) , ^?{}( volatile double _Complex * );695 void ^?{}( long double _Complex * ) , ^?{}( volatile long double _Complex * );678 void ^?{}( _Bool * ); 679 void ^?{}( char * ); 680 void ^?{}( char unsigned * ); 681 void ^?{}( char signed * ); 682 void ^?{}( int short * ); 683 void ^?{}( int short unsigned * ); 684 void ^?{}( signed int * ); 685 void ^?{}( unsigned int * ); 686 void ^?{}( signed long int * ); 687 void ^?{}( unsigned long int * ); 688 void ^?{}( signed long long int * ); 689 void ^?{}( unsigned long long int * ); 690 void ^?{}( float * ); 691 void ^?{}( double * ); 692 void ^?{}( long double * ); 693 void ^?{}( float _Complex * ); 694 void ^?{}( double _Complex * ); 695 void ^?{}( long double _Complex * ); 696 696 697 697 // // default ctor … … 719 719 720 720 forall( dtype DT ) void ?{}( DT * *, DT * ); 721 forall( dtype DT ) void ?{}( DT * volatile *, DT * );722 721 forall( dtype DT ) void ?{}( const DT * *, DT * ); 723 forall( dtype DT ) void ?{}( const DT * volatile *, DT * );724 722 forall( dtype DT ) void ?{}( const DT * *, const DT * ); 725 forall( dtype DT ) void ?{}( const DT * volatile *, const DT * );726 723 forall( dtype DT ) void ?{}( volatile DT * *, DT * ); 727 forall( dtype DT ) void ?{}( volatile DT * volatile *, DT * );728 724 forall( dtype DT ) void ?{}( volatile DT * *, volatile DT * ); 729 forall( dtype DT ) void ?{}( volatile DT * volatile *, volatile DT * );730 725 731 726 forall( dtype DT ) void ?{}( const volatile DT * *, DT * ); 732 forall( dtype DT ) void ?{}( const volatile DT * volatile *, DT * );733 727 forall( dtype DT ) void ?{}( const volatile DT * *, const DT * ); 734 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const DT * );735 728 forall( dtype DT ) void ?{}( const volatile DT * *, volatile DT * ); 736 forall( dtype DT ) void ?{}( const volatile DT * volatile *, volatile DT * );737 729 forall( dtype DT ) void ?{}( const volatile DT * *, const volatile DT * ); 738 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const volatile DT * );739 730 740 731 forall( dtype DT ) void ?{}( DT * *, void * ); 741 forall( dtype DT ) void ?{}( DT * volatile *, void * );742 732 forall( dtype DT ) void ?{}( const DT * *, void * ); 743 forall( dtype DT ) void ?{}( const DT * volatile *, void * );744 733 forall( dtype DT ) void ?{}( const DT * *, const void * ); 745 forall( dtype DT ) void ?{}( const DT * volatile *, const void * );746 734 forall( dtype DT ) void ?{}( volatile DT * *, void * ); 747 forall( dtype DT ) void ?{}( volatile DT * volatile *, void * );748 735 forall( dtype DT ) void ?{}( volatile DT * *, volatile void * ); 749 forall( dtype DT ) void ?{}( volatile DT * volatile *, volatile void * );750 736 751 737 forall( dtype DT ) void ?{}( const volatile DT * *, void * ); 752 forall( dtype DT ) void ?{}( const volatile DT * volatile *, void * );753 738 forall( dtype DT ) void ?{}( const volatile DT * *, const void * ); 754 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const void * );755 739 forall( dtype DT ) void ?{}( const volatile DT * *, volatile void * ); 756 forall( dtype DT ) void ?{}( const volatile DT * volatile *, volatile void * );757 740 forall( dtype DT ) void ?{}( const volatile DT * *, const volatile void * ); 758 forall( dtype DT ) void ?{}( const volatile DT * volatile *, const volatile void * );759 741 760 742 forall( dtype DT ) void ?{}( void * *, DT * ); 761 forall( dtype DT ) void ?{}( void * volatile *, DT * );762 743 forall( dtype DT ) void ?{}( const void * *, DT * ); 763 forall( dtype DT ) void ?{}( const void * volatile *, DT * );764 744 forall( dtype DT ) void ?{}( const void * *, const DT * ); 765 forall( dtype DT ) void ?{}( const void * volatile *, const DT * );766 745 forall( dtype DT ) void ?{}( volatile void * *, DT * ); 767 forall( dtype DT ) void ?{}( volatile void * volatile *, DT * );768 746 forall( dtype DT ) void ?{}( volatile void * *, volatile DT * ); 769 forall( dtype DT ) void ?{}( volatile void * volatile *, volatile DT * );770 747 forall( dtype DT ) void ?{}( const volatile void * *, DT * ); 771 forall( dtype DT ) void ?{}( const volatile void * volatile *, DT * );772 748 forall( dtype DT ) void ?{}( const volatile void * *, const DT * ); 773 forall( dtype DT ) void ?{}( const volatile void * volatile *, const DT * );774 749 forall( dtype DT ) void ?{}( const volatile void * *, volatile DT * ); 775 forall( dtype DT ) void ?{}( const volatile void * volatile *, volatile DT * );776 750 forall( dtype DT ) void ?{}( const volatile void * *, const volatile DT * ); 777 forall( dtype DT ) void ?{}( const volatile void * volatile *, const volatile DT * );778 751 779 752 void ?{}( void * *, void * ); 780 void ?{}( void * volatile *, void * );781 753 void ?{}( const void * *, void * ); 782 void ?{}( const void * volatile *, void * );783 754 void ?{}( const void * *, const void * ); 784 void ?{}( const void * volatile *, const void * );785 755 void ?{}( volatile void * *, void * ); 786 void ?{}( volatile void * volatile *, void * );787 756 void ?{}( volatile void * *, volatile void * ); 788 void ?{}( volatile void * volatile *, volatile void * );789 757 void ?{}( const volatile void * *, void * ); 790 void ?{}( const volatile void * volatile *, void * );791 758 void ?{}( const volatile void * *, const void * ); 792 void ?{}( const volatile void * volatile *, const void * );793 759 void ?{}( const volatile void * *, volatile void * ); 794 void ?{}( const volatile void * volatile *, volatile void * );795 760 void ?{}( const volatile void * *, const volatile void * ); 796 void ?{}( const volatile void * volatile *, const volatile void * );797 761 798 762 //forall( dtype DT ) void ?{}( DT * *, forall( dtype DT2 ) const DT2 * ); 799 763 //forall( dtype DT ) void ?{}( DT * volatile *, forall( dtype DT2 ) const DT2 * ); 800 764 forall( dtype DT ) void ?{}( const DT * *, forall( dtype DT2 ) const DT2 * ); 801 forall( dtype DT ) void ?{}( const DT * volatile *, forall( dtype DT2 ) const DT2 * );802 765 //forall( dtype DT ) void ?{}( volatile DT * *, forall( dtype DT2 ) const DT2 * ); 803 766 //forall( dtype DT ) void ?{}( volatile DT * volatile *, forall( dtype DT2 ) const DT2 * ); 804 767 forall( dtype DT ) void ?{}( const volatile DT * *, forall( dtype DT2 ) const DT2 * ); 805 forall( dtype DT ) void ?{}( const volatile DT * volatile *, forall( dtype DT2 ) const DT2 * );806 768 807 769 forall( ftype FT ) void ?{}( FT * *, forall( ftype FT2 ) FT2 * ); 808 forall( ftype FT ) void ?{}( FT * volatile *, forall( ftype FT2 ) FT2 * );809 770 810 771 // default ctors 811 772 forall( ftype FT ) void ?{}( FT * * ); 812 forall( ftype FT ) void ?{}( FT * volatile * );813 773 814 774 forall( dtype DT ) void ?{}( DT * *); 815 forall( dtype DT ) void ?{}( DT * volatile *);816 775 forall( dtype DT ) void ?{}( const DT * *); 817 forall( dtype DT ) void ?{}( const DT * volatile *);818 776 forall( dtype DT ) void ?{}( volatile DT * *); 819 forall( dtype DT ) void ?{}( volatile DT * volatile *);820 777 forall( dtype DT ) void ?{}( const volatile DT * *); 821 forall( dtype DT ) void ?{}( const volatile DT * volatile *);822 778 823 779 void ?{}( void * *); 824 void ?{}( void * volatile *);825 780 void ?{}( const void * *); 826 void ?{}( const void * volatile *);827 781 void ?{}( volatile void * *); 828 void ?{}( volatile void * volatile *);829 782 void ?{}( const volatile void * *); 830 void ?{}( const volatile void * volatile *);831 783 832 784 // dtors 833 785 forall( ftype FT ) void ^?{}( FT * * ); 834 forall( ftype FT ) void ^?{}( FT * volatile * );835 786 836 787 forall( dtype DT ) void ^?{}( DT * *); 837 forall( dtype DT ) void ^?{}( DT * volatile *);838 788 forall( dtype DT ) void ^?{}( const DT * *); 839 forall( dtype DT ) void ^?{}( const DT * volatile *);840 789 forall( dtype DT ) void ^?{}( volatile DT * *); 841 forall( dtype DT ) void ^?{}( volatile DT * volatile *);842 790 forall( dtype DT ) void ^?{}( const volatile DT * *); 843 forall( dtype DT ) void ^?{}( const volatile DT * volatile *);844 791 845 792 void ^?{}( void * *); 846 void ^?{}( void * volatile *);847 793 void ^?{}( const void * *); 848 void ^?{}( const void * volatile *);849 794 void ^?{}( volatile void * *); 850 void ^?{}( volatile void * volatile *);851 795 void ^?{}( const volatile void * *); 852 void ^?{}( const volatile void * volatile *);853 796 854 797 // Local Variables: // -
TabularUnified src/tests/.expect/declarationErrors.txt ¶
rf5e81d1 radd7117 1 1 CFA Version 1.0.0 (debug) 2 Error: invalid combination of storage classes in declaration of x9: static const volatile short int2 Error: duplicate static in declaration of x1: static const volatile short int 3 3 4 Error: invalid combination of storage classes in declaration of x18: static const volatile instance of const volatile struct __anonymous0 4 Error: multiple extern & static in declaration of x2: extern const volatile short int 5 6 Error: multiple extern & auto, multiple extern & static, multiple extern & static, duplicate extern in declaration of x3: extern const volatile short int 7 8 Error: duplicate static in declaration of x4: static const volatile instance of const volatile struct __anonymous0 5 9 with members 6 10 with body 7 11 8 12 9 Error: duplicate qualifier volatile in declaration of x19: static const volatile instance of const volatile struct __anonymous113 Error: duplicate const, duplicate static, duplicate volatile in declaration of x5: static const volatile instance of const volatile struct __anonymous1 10 14 with members 11 15 with body 12 16 13 17 14 Error: invalid combination of storage classes in declaration of x28: static const volatile instance of type Int18 Error: duplicate static in declaration of x6: static const volatile instance of type Int 15 19 16 Error: duplicate qualifierconst in declaration of f01: static inline function20 Error: duplicate const in declaration of f01: static inline function 17 21 with no parameters 18 22 returning const volatile int 19 23 20 24 21 Error: duplicate qualifiervolatile in declaration of f02: static inline function25 Error: duplicate volatile in declaration of f02: static inline function 22 26 with no parameters 23 27 returning const volatile int 24 28 25 29 26 Error: duplicate qualifierconst in declaration of f03: static inline function30 Error: duplicate const in declaration of f03: static inline function 27 31 with no parameters 28 32 returning const volatile int 29 33 30 34 31 Error: duplicate qualifiervolatile in declaration of f04: static inline function35 Error: duplicate volatile in declaration of f04: static inline function 32 36 with no parameters 33 37 returning const volatile int 34 38 35 39 36 Error: duplicate qualifierconst in declaration of f05: static inline function40 Error: duplicate const in declaration of f05: static inline function 37 41 with no parameters 38 42 returning const volatile int 39 43 40 44 41 Error: duplicate qualifiervolatile in declaration of f06: static inline function45 Error: duplicate volatile in declaration of f06: static inline function 42 46 with no parameters 43 47 returning const volatile int 44 48 45 49 46 Error: duplicate qualifierconst in declaration of f07: static inline function50 Error: duplicate const in declaration of f07: static inline function 47 51 with no parameters 48 52 returning const volatile int 49 53 50 54 51 Error: duplicate qualifier const,volatile in declaration of f08: static inline function55 Error: duplicate const, duplicate volatile in declaration of f08: static inline function 52 56 with no parameters 53 57 returning const volatile int 54 58 55 59 56 Error: duplicate qualifier const,volatile in declaration of f09: static inline function60 Error: duplicate const, duplicate volatile in declaration of f09: static inline function 57 61 with no parameters 58 62 returning const volatile int 59 63 60 64 61 Error: duplicate qualifier const,volatile in declaration of f09: static inline function65 Error: duplicate const, duplicate _Atomic, duplicate _Atomic, duplicate const, duplicate restrict, duplicate volatile in declaration of f09: static inline function 62 66 with no parameters 63 returning const volatileint67 returning const restrict volatile _Atomic int 64 68 65 69 -
TabularUnified src/tests/declarationErrors.c ¶
rf5e81d1 radd7117 10 10 // Created On : Wed Aug 17 08:23:43 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 25 18:16:40201613 // Update Count : 512 // Last Modified On : Fri Sep 9 22:57:52 2016 13 // Update Count : 31 14 14 // 15 15 16 static short int volatile static const x9; // duplicate static 17 struct { int i; } const static volatile static x18; // duplicate static 18 struct { int i; } const static volatile static volatile x19; // duplicate static & volatile 16 static short int volatile static const x1; // duplicate static 17 extern short int static volatile const x2; // multiple extern & static 18 extern short int auto static volatile static extern const x3; // duplicate and multiple storage classes 19 struct { int i; } const static volatile static x4; // duplicate static 20 struct { int i; } const static volatile const static volatile x5; // duplicate static & const & volatile 19 21 typedef int Int; 20 static Int volatile static const x 28; // duplicate static22 static Int volatile static const x6; // duplicate static 21 23 22 24 const static inline const volatile int f01(); // duplicate const … … 24 26 const inline const volatile int static f03(); // duplicate const 25 27 volatile inline static const volatile int f04(); // duplicate volatile 26 const static const inline volatile intf05(); // duplicate const27 volatile static const volatile inline intf06(); // duplicate volatile28 const static const volatile intinline f07(); // duplicate const29 volatile static const int inline const volatile f08(); 28 const static int const inline volatile f05(); // duplicate const 29 volatile int static const volatile inline f06(); // duplicate volatile 30 const static const int volatile inline f07(); // duplicate const 31 volatile static const int inline const volatile f08(); // duplicate volatile 30 32 31 volatile static const int inline const volatile f09(); 32 volatile static const int inline const volatile f09();// duplicate volatile33 volatile static const int inline const volatile f09(); // duplicate volatile 34 _Atomic _Atomic _Atomic volatile restrict static const const int inline restrict const volatile f09(); // duplicate volatile 33 35 34 36 //Dummy main -
TabularUnified src/tests/test.py ¶
rf5e81d1 radd7117 285 285 # check if the user already passed in a number of jobs for multi-threading 286 286 make_flags = environ.get('MAKEFLAGS') 287 make_has_max_jobs = re.search("(-j|--jobs)\s*([0-9]+)", make_flags) if make_flags else None 288 make_max_jobs = make_has_max_jobs.group(2) if make_has_max_jobs else None 289 make_cmd = "make" if make_flags and "-j" in make_flags else "make -j8" 287 make_jobs_fds = re.search("--jobserver-fds=\s*([0-9]+),([0-9]+)", make_flags) if make_flags else None 288 if make_jobs_fds : 289 tokens = os.read(int(make_jobs_fds.group(1)), 1024) 290 options.jobs = len(tokens) 291 os.write(int(make_jobs_fds.group(2)), tokens) 290 292 291 293 # make sure we have a valid number of jobs that corresponds to user input 292 options.jobs = int(make_max_jobs) if make_max_jobs else (options.jobs if options.jobs else 1)293 294 if options.jobs <= 0 : 294 295 print('ERROR: Invalid number of jobs', file=sys.stderr) … … 296 297 297 298 print('Running on %i cores' % options.jobs) 299 make_cmd = "make" if make_flags else ("make -j%i" % options.jobs) 298 300 299 301 # users may want to simply list the tests
Note: See TracChangeset
for help on using the changeset viewer.