Changeset 12df6fe
- Timestamp:
- Sep 19, 2022, 11:48:13 AM (3 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- 4520b77e
- Parents:
- b0d9ff7
- Files:
-
- 8 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/CodeGen/CodeGenerator.cc ¶
rb0d9ff7 r12df6fe 277 277 std::list< Declaration* > &memb = enumDecl->get_members(); 278 278 if (enumDecl->base && ! memb.empty()) { 279 unsigned long long last_val = -1; 279 unsigned long long last_val = -1; // if the first enum value has no explicit initializer, 280 // as other 280 281 for ( std::list< Declaration* >::iterator i = memb.begin(); i != memb.end(); i++) { 281 282 ObjectDecl * obj = dynamic_cast< ObjectDecl* >( *i ); … … 289 290 if ( obj->get_init() ) { 290 291 obj->get_init()->accept( *visitor ); 291 //last_val = ((ConstantExpr *)(((SingleInit *)(obj->init))->value))->constant.get_ival();292 last_val = ((ConstantExpr *)(((SingleInit *)(obj->init))->value))->constant.get_ival(); 292 293 } else { 293 294 output << ++last_val; -
TabularUnified src/Parser/TypeData.cc ¶
rb0d9ff7 r12df6fe 926 926 list< Declaration * >::iterator members = ret->get_members().begin(); 927 927 for ( const DeclarationNode * cur = td->enumeration.constants; cur != nullptr; cur = dynamic_cast< DeclarationNode * >( cur->get_next() ), ++members ) { 928 if ( ret->isTyped && cur->has_enumeratorValue() ) {928 if ( ret->isTyped && !ret->base && cur->has_enumeratorValue() ) { 929 929 SemanticError( td->location, "Enumerator of enum(void) cannot have an explicit initializer value." ); 930 930 } else if ( cur->has_enumeratorValue() ) { -
TabularUnified src/ResolvExpr/Resolver.cc ¶
rb0d9ff7 r12df6fe 1478 1478 // enum type is still incomplete at this point. Use `int` instead. 1479 1479 1480 if (dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() )->base->base) { 1480 if ( auto enumBase = dynamic_cast< const ast::EnumInstType * > 1481 ( objectDecl->get_type() )->base->base ) { 1481 1482 objectDecl = fixObjectType( objectDecl, context ); 1482 const ast::Type * enumBase = (dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() )->base->base.get());1483 1483 currentObject = ast::CurrentObject{ 1484 1484 objectDecl->location, … … 1493 1493 } 1494 1494 else { 1495 if ( !objectDecl->isTypeFixed) {1495 if ( !objectDecl->isTypeFixed ) { 1496 1496 auto newDecl = fixObjectType(objectDecl, context); 1497 1497 auto mutDecl = mutate(newDecl); -
TabularUnified tests/enum_tests/structEnum.cfa ¶
rb0d9ff7 r12df6fe 24 24 struct Point apple = first; 25 25 // Failed due to Qualified name is currently unimplemented. 26 struct Point banana = PointEnum.first;27 26 28 27 int main() { 29 28 PointEnum vals = second; 30 29 PointEnum val2; 31 // P132 val2 = vals;30 // The failing line: assignment 31 // val2 = vals; 33 32 34 33 printf("%d %c\n", apple.x, apple.y);
Note: See TracChangeset
for help on using the changeset viewer.