Changeset a436947
- Timestamp:
- Jun 7, 2016, 3:59:15 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- d0f8b19
- Parents:
- db175c8
- Location:
- src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/CommonType.cc
rdb175c8 ra436947 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // CommonType.cc -- 7 // CommonType.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 134 134 result = new BasicType( basicType->get_qualifiers() + otherBasic->get_qualifiers(), newType ); 135 135 } // if 136 } else if ( EnumInstType *enumInstType = dynamic_cast< EnumInstType * > ( type2 ) ) { 137 // use signed int in lieu of the enum type 138 BasicType::Kind newType = combinedType[ basicType->get_kind() ][ BasicType::SignedInt ]; 139 if ( ( ( newType == basicType->get_kind() && basicType->get_qualifiers() >= enumInstType->get_qualifiers() ) || widenFirst ) && ( ( newType != basicType->get_kind() && basicType->get_qualifiers() <= enumInstType->get_qualifiers() ) || widenSecond ) ) { 140 result = new BasicType( basicType->get_qualifiers() + enumInstType->get_qualifiers(), newType ); 141 } // if 136 142 } // if 137 143 } … … 183 189 } 184 190 185 void CommonType::visit( EnumInstType *aggregateUseType ) { 191 void CommonType::visit( EnumInstType *enumInstType ) { 192 if ( dynamic_cast< BasicType * >( type2 ) ) { 193 // reuse BasicType, EnumInstType code by swapping type2 with enumInstType 194 Type * temp = type2; 195 type2 = enumInstType; 196 temp->accept( *this ); 197 type2 = temp; 198 } // if 186 199 } 187 200 -
src/ResolvExpr/ConversionCost.cc
rdb175c8 ra436947 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ConversionCost.cc -- 7 // ConversionCost.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 157 157 cost = Cost( 0, 0, tableResult ); 158 158 } // if 159 } // if 159 } else if ( dynamic_cast< EnumInstType *>( dest ) ) { 160 // xxx - not positive this is correct, but appears to allow casting int => enum 161 cost = Cost( 1, 0, 0 ); 162 } // if 160 163 } 161 164 -
src/ResolvExpr/Resolver.cc
rdb175c8 ra436947 38 38 virtual void visit( ObjectDecl *functionDecl ); 39 39 virtual void visit( TypeDecl *typeDecl ); 40 virtual void visit( EnumDecl * enumDecl ); 40 41 41 42 virtual void visit( ArrayType * at ); … … 66 67 Type *initContext; 67 68 Type *switchType; 69 bool inEnumDecl = false; 68 70 }; 69 71 … … 178 180 Type *temp = initContext; 179 181 initContext = new_type; 182 if ( inEnumDecl && dynamic_cast< EnumInstType * >( initContext ) ) { 183 // enumerator initializers should not use the enum type to initialize, since 184 // the enum type is still incomplete at this point. Use signed int instead. 185 initContext = new BasicType( Type::Qualifiers(), BasicType::SignedInt ); 186 } 180 187 SymTab::Indexer::visit( objectDecl ); 188 if ( inEnumDecl && dynamic_cast< EnumInstType * >( initContext ) ) { 189 // delete newly created signed int type 190 delete initContext; 191 } 181 192 initContext = temp; 182 193 } … … 216 227 SymTab::Indexer::visit( functionDecl ); 217 228 functionReturn = oldFunctionReturn; 229 } 230 231 void Resolver::visit( EnumDecl * enumDecl ) { 232 // in case we decide to allow nested enums 233 bool oldInEnumDecl = inEnumDecl; 234 inEnumDecl = true; 235 SymTab::Indexer::visit( enumDecl ); 236 inEnumDecl = oldInEnumDecl; 218 237 } 219 238 -
src/SymTab/Validate.cc
rdb175c8 ra436947 279 279 void Pass1::visit( EnumDecl *enumDecl ) { 280 280 // Set the type of each member of the enumeration to be EnumConstant 281 282 281 for ( std::list< Declaration * >::iterator i = enumDecl->get_members().begin(); i != enumDecl->get_members().end(); ++i ) { 283 282 ObjectDecl * obj = dynamic_cast< ObjectDecl * >( *i ); 284 283 assert( obj ); 285 // obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false, false, false ), enumDecl->get_name() ) ); 286 BasicType * enumType = new BasicType( Type::Qualifiers(), BasicType::SignedInt ); 287 obj->set_type( enumType ) ; 284 obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false, false, false ), enumDecl->get_name() ) ); 288 285 } // for 289 286 Parent::visit( enumDecl ); -
src/SynTree/Attribute.h
rdb175c8 ra436947 20 20 21 21 // GCC attribute 22 // https://gcc.gnu.org/onlinedocs/gcc /Attribute-Syntax.html#Attribute-Syntax22 // https://gcc.gnu.org/onlinedocs/gcc-6.1.0/gcc/Attribute-Syntax.html#Attribute-Syntax 23 23 class Attribute { 24 24 public:
Note: See TracChangeset
for help on using the changeset viewer.