Changeset 062e8df
- Timestamp:
- Jul 9, 2018, 10:31:04 AM (6 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, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 0bcc2b7
- Parents:
- 49e1275
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
r49e1275 r062e8df 351 351 352 352 Type * FixQualifiedTypes::postmutate( QualifiedType * qualType ) { 353 // TODO: change asserts to SemanticErrors as necessary354 353 Type * parent = qualType->parent; 355 354 Type * child = qualType->child; 356 355 if ( dynamic_cast< GlobalScopeType * >( qualType->parent ) ) { 357 356 // .T => lookup T at global scope 358 if ( StructInstType * inst = dynamic_cast< StructInstType * >( child ) ) { 359 auto aggr = indexer.globalLookupStruct( inst->name ); 360 return new StructInstType( qualType->get_qualifiers(), aggr ); 361 } else if ( UnionInstType * inst = dynamic_cast< UnionInstType * >( child ) ) { 362 auto aggr = indexer.globalLookupUnion( inst->name ); 363 return new UnionInstType( qualType->get_qualifiers(), aggr ); 364 } else if ( EnumInstType * inst = dynamic_cast< EnumInstType * >( child ) ) { 365 auto aggr = indexer.globalLookupEnum( inst->name ); 366 return new EnumInstType( qualType->get_qualifiers(), aggr ); 367 } else if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( child ) ) { 357 if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( child ) ) { 368 358 auto td = indexer.globalLookupType( inst->name ); 369 assertf( td, "did not find type at global scope with name: %s", inst->name.c_str() ); 359 if ( ! td ) { 360 SemanticError( qualType->location, toString("Use of undefined global type ", inst->name) ); 361 } 370 362 auto base = td->base; 371 if ( base ) return td->base->clone();372 assert( false);363 assert( base ); 364 return base->clone(); 373 365 } else { 374 // .T => T is not a SUEtype name375 assert ( false);366 // .T => T is not a type name 367 assertf( false, "unhandled global qualified child type: %s", toCString(child) ); 376 368 } 377 369 } else { … … 383 375 aggr = inst->baseUnion; 384 376 } else { 385 assert( false);377 SemanticError( qualType->location, toString("Qualified type requires an aggregate on the left, but has: ", parent) ); 386 378 } 387 379 assert( aggr ); // TODO: need to handle forward declarations … … 409 401 if ( NamedTypeDecl * aggr = dynamic_cast< NamedTypeDecl * > ( member ) ) { 410 402 if ( aggr->name == inst->name ) { 411 if ( aggr->base ) return aggr->base->clone();412 assert( false);403 assert( aggr->base ); 404 return aggr->base->clone(); 413 405 } 414 406 } … … 419 411 } 420 412 // failed to find a satisfying definition of type 421 assertf( false, "failed to find a satisfying definition of %s in %s", toCString(child), toCString(parent) );413 SemanticError( qualType->location, toString("Undefined type in qualified type: ", qualType) ); 422 414 } 423 415 … … 919 911 } else { 920 912 TypeDeclMap::const_iterator base = typedeclNames.find( typeInst->name ); 921 assertf( base != typedeclNames.end(), "Cannot find typedecl name %s", typeInst->name.c_str() ); 913 if ( base == typedeclNames.end() ) { 914 SemanticError( typeInst->location, toString("Use of undefined type ", typeInst->name) ); 915 } 922 916 typeInst->set_baseType( base->second ); 923 } // if 924 return typeInst; 917 return typeInst; 918 } // if 919 assert( false ); 925 920 } 926 921
Note: See TracChangeset
for help on using the changeset viewer.