Changes in / [24ceace:4b4f95f]
- Location:
- src
- Files:
-
- 7 edited
-
AST/Convert.cpp (modified) (1 diff)
-
Parser/DeclarationNode.cc (modified) (3 diffs)
-
Parser/ParseNode.h (modified) (1 diff)
-
Parser/TypeData.cc (modified) (2 diffs)
-
Parser/parser.yy (modified) (4 diffs)
-
ResolvExpr/Resolver.cc (modified) (2 diffs)
-
SymTab/Validate.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r24ceace r4b4f95f 1730 1730 } 1731 1731 1732 1732 // Convert SynTree::EnumDecl to AST::EnumDecl 1733 1733 virtual void visit( const EnumDecl * old ) override final { 1734 1734 if ( inCache( old ) ) return; -
src/Parser/DeclarationNode.cc
r24ceace r4b4f95f 253 253 } // DeclarationNode::newAggregate 254 254 255 DeclarationNode * DeclarationNode::newEnum( const string * name, DeclarationNode * constants, bool body , DeclarationNode * base) {255 DeclarationNode * DeclarationNode::newEnum( const string * name, DeclarationNode * constants, bool body) { 256 256 DeclarationNode * newnode = new DeclarationNode; 257 257 newnode->type = new TypeData( TypeData::Enum ); … … 260 260 newnode->type->enumeration.body = body; 261 261 newnode->type->enumeration.anon = name == nullptr; 262 if ( base && base->type) {263 newnode->type->base = base->type;264 } // if265 266 // Check: if base has TypeData267 262 return newnode; 268 263 } // DeclarationNode::newEnum … … 295 290 return newName( name ); // Not explicitly inited enum value; 296 291 } // if 297 } // DeclarationNode::newEnum ValueGeneric292 } // DeclarationNode::newEnumGeneric 298 293 299 294 DeclarationNode * DeclarationNode::newFromTypedef( const string * name ) { -
src/Parser/ParseNode.h
r24ceace r4b4f95f 235 235 static DeclarationNode * newFunction( const std::string * name, DeclarationNode * ret, DeclarationNode * param, StatementNode * body ); 236 236 static DeclarationNode * newAggregate( AggregateDecl::Aggregate kind, const std::string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ); 237 static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body , DeclarationNode * base = nullptr);237 static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body ); 238 238 static DeclarationNode * newEnumConstant( const std::string * name, ExpressionNode * constant ); 239 239 static DeclarationNode * newEnumValueGeneric( const std::string * name, InitializerNode * init ); -
src/Parser/TypeData.cc
r24ceace r4b4f95f 388 388 if ( enumeration.body ) { 389 389 os << string( indent + 2, ' ' ) << " with body" << endl; 390 } // if391 if ( base ) {392 os << "for ";393 base->print( os, indent + 2 );394 390 } // if 395 391 break; … … 930 926 ObjectDecl * member = dynamic_cast< ObjectDecl * >(* members); 931 927 member->set_init( new SingleInit( maybeMoveBuild< Expression >( cur->consume_enumeratorValue() ) ) ); 932 } else if ( !cur->initializer ){928 } else { 933 929 if ( baseType && (!dynamic_cast<BasicType *>(baseType) || !dynamic_cast<BasicType *>(baseType)->isWholeNumber())) { 934 930 SemanticError( td->location, "A non whole number enum value decl must be explicitly initialized." ); 935 931 } 936 } 937 // else cur is a List Initializer and has been set as init in buildList() 938 // if 932 } // if 939 933 } // for 940 ret->set_body( td->enumeration.body ); 934 ret->set_body( td->enumeration.body ); // Boolean; if it has body 941 935 return ret; 942 936 } // buildEnum -
src/Parser/parser.yy
r24ceace r4b4f95f 2303 2303 ; 2304 2304 2305 enum_type: 2305 enum_type: // static DeclarationNode * newEnum( const std::string * name, DeclarationNode * constants, bool body, bool typed ); // enum 2306 2306 ENUM attribute_list_opt '{' enumerator_list comma_opt '}' 2307 2307 { $$ = DeclarationNode::newEnum( nullptr, $4, true )->addQualifiers( $2 ); } … … 2318 2318 { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } 2319 2319 2320 $$ = DeclarationNode::newEnum( nullptr, $7, true , $3 ) ->addQualifiers( $5);2321 } 2322 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt 2320 $$ = DeclarationNode::newEnum( nullptr, $7, true ) ->addQualifiers( $5 ) -> addEnumBase( $3 ); 2321 } 2322 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt identifier attribute_list_opt // Question: why attributes/qualifier after identifier 2323 2323 { 2324 2324 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } … … 2327 2327 '{' enumerator_list comma_opt '}' 2328 2328 { 2329 $$ = DeclarationNode::newEnum( $6, $10, true , $3 ) -> addQualifiers( $5 ) -> addQualifiers( $7);2329 $$ = DeclarationNode::newEnum( $6, $10, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ) -> addEnumBase( $3 ); 2330 2330 } 2331 2331 | ENUM '(' cfa_abstract_parameter_declaration ')' attribute_list_opt typedef_name attribute_list_opt '{' enumerator_list comma_opt '}' … … 2333 2333 if ( $3->storageClasses.val != 0 || $3->type->qualifiers.val != 0 ) { SemanticError( yylloc, "storage-class and CV qualifiers are not meaningful for enumeration constants, which are const." ); } 2334 2334 typedefTable.makeTypedef( *$6->name ); 2335 $$ = DeclarationNode::newEnum( $6->name, $9, true , $3 ) -> addQualifiers( $5 ) -> addQualifiers( $7);2335 $$ = DeclarationNode::newEnum( $6->name, $9, true ) -> addQualifiers( $5 ) -> addQualifiers( $7 ) -> addEnumBase( $3 ); 2336 2336 } 2337 2337 | enum_type_nobody -
src/ResolvExpr/Resolver.cc
r24ceace r4b4f95f 427 427 // enumerator initializers should not use the enum type to initialize, since 428 428 // the enum type is still incomplete at this point. Use signed int instead. 429 // TODO: BasicType::SignedInt may not longer be true430 429 currentObject = CurrentObject( new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ); 431 430 } … … 1478 1477 // enum type is still incomplete at this point. Use `int` instead. 1479 1478 1480 if (dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() )->base->base) { 1479 if (dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() )->base->base) { // const ast::PointerType & 1480 // const ast::Type * enumBase = (dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() )->base->base.get()); 1481 // const ast::PointerType * enumBaseAsPtr = dynamic_cast<const ast::PointerType *>(enumBase); 1482 1483 // if ( enumBaseAsPtr ) { 1484 // const ast::Type * pointerBase = enumBaseAsPtr->base.get(); 1485 // if ( dynamic_cast<const ast::BasicType *>(pointerBase) ) { 1486 // objectDecl = fixObjectType(objectDecl, context); 1487 // if (dynamic_cast<const ast::BasicType *>(pointerBase)->kind == ast::BasicType::Char) 1488 // currentObject = ast::CurrentObject{ 1489 // objectDecl->location, new ast::PointerType{ 1490 // new ast::BasicType{ ast::BasicType::Char } 1491 // } }; 1492 // } else { 1493 // objectDecl = fixObjectType(objectDecl, context); 1494 // currentObject = ast::CurrentObject{objectDecl->location, new ast::BasicType{ ast::BasicType::SignedInt } }; 1495 // } 1496 // } 1481 1497 objectDecl = fixObjectType( objectDecl, context ); 1482 1498 const ast::Type * enumBase = (dynamic_cast< const ast::EnumInstType * >( objectDecl->get_type() )->base->base.get()); -
src/SymTab/Validate.cc
r24ceace r4b4f95f 765 765 } // if 766 766 } 767 767 768 void LinkReferenceToTypes_old::postvisit( StructInstType * structInst ) { 768 769 const StructDecl * st = local_indexer->lookupStruct( structInst->name ); … … 890 891 void LinkReferenceToTypes_old::postvisit( EnumDecl * enumDecl ) { 891 892 // visit enum members first so that the types of self-referencing members are updated properly 892 // Replace the enum base; right now it works only for StructEnum893 if ( enumDecl->base && dynamic_cast<TypeInstType*>(enumDecl->base) ) {894 std::string baseName = static_cast<TypeInstType*>(enumDecl->base)->name;895 const StructDecl * st = local_indexer->lookupStruct( baseName );896 if ( st ) {897 enumDecl->base = new StructInstType(Type::Qualifiers(),const_cast<StructDecl *>(st)); // Just linking in the node898 }899 }900 893 if ( enumDecl->body ) { 901 894 ForwardEnumsType::iterator fwds = forwardEnums.find( enumDecl->name );
Note:
See TracChangeset
for help on using the changeset viewer.