Changeset 11ab8ea8
- Timestamp:
- May 19, 2017, 3:44:49 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 88e0080
- Parents:
- d298e03
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
rd298e03 r11ab8ea8 208 208 }; 209 209 210 /// ensure that generic types have the correct number of type arguments 211 class ValidateGenericParameters : public Visitor { 212 public: 213 typedef Visitor Parent; 214 virtual void visit( StructInstType * inst ) final override; 215 virtual void visit( UnionInstType * inst ) final override; 216 }; 217 210 218 class ArrayLength : public Visitor { 211 219 public: … … 235 243 Pass3 pass3( 0 ); 236 244 CompoundLiteral compoundliteral; 237 238 HoistStruct::hoistStruct( translationUnit ); 245 ValidateGenericParameters genericParams; 246 239 247 EliminateTypedef::eliminateTypedef( translationUnit ); 248 HoistStruct::hoistStruct( translationUnit ); // must happen after EliminateTypedef, so that aggregate typedefs occur in the correct order 240 249 ReturnTypeFixer::fix( translationUnit ); // must happen before autogen 241 250 acceptAll( translationUnit, lrt ); // must happen before autogen, because sized flag needs to propagate to generated functions 251 acceptAll( translationUnit, genericParams ); // check as early as possible - can't happen before LinkReferenceToTypes 242 252 acceptAll( translationUnit, epc ); // must happen before VerifyCtorDtorAssign, because void return objects should not exist 243 253 VerifyCtorDtorAssign::verify( translationUnit ); // must happen before autogen, because autogen examines existing ctor/dtors … … 829 839 } 830 840 841 template< typename Aggr > 842 void validateGeneric( Aggr * inst ) { 843 std::list< TypeDecl * > * params = inst->get_baseParameters(); 844 if ( params != NULL ) { 845 std::list< Expression * > & args = inst->get_parameters(); 846 if ( args.size() < params->size() ) throw SemanticError( "Too few type arguments in generic type ", inst ); 847 if ( args.size() > params->size() ) throw SemanticError( "Too many type arguments in generic type ", inst ); 848 } 849 } 850 851 void ValidateGenericParameters::visit( StructInstType * inst ) { 852 validateGeneric( inst ); 853 Parent::visit( inst ); 854 } 855 856 void ValidateGenericParameters::visit( UnionInstType * inst ) { 857 validateGeneric( inst ); 858 Parent::visit( inst ); 859 } 860 831 861 DeclarationWithType * CompoundLiteral::mutate( ObjectDecl *objectDecl ) { 832 862 storageClasses = objectDecl->get_storageClasses();
Note: See TracChangeset
for help on using the changeset viewer.