Changes in src/Parser/DeclarationNode.cc [284da8c:c194661]
- File:
-
- 1 edited
-
src/Parser/DeclarationNode.cc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r284da8c rc194661 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jul 6 06:56:08201813 // Update Count : 10 8812 // Last Modified On : Thu Jun 7 12:08:55 2018 13 // Update Count : 1079 14 14 // 15 15 … … 254 254 } // DeclarationNode::newFromTypedef 255 255 256 DeclarationNode * DeclarationNode::newFromGlobalScope() { 257 DeclarationNode * newnode = new DeclarationNode; 258 newnode->type = new TypeData( TypeData::GlobalScope ); 259 return newnode; 260 } 261 262 DeclarationNode * DeclarationNode::newQualifiedType( DeclarationNode * parent, DeclarationNode * child) { 263 DeclarationNode * newnode = new DeclarationNode; 264 newnode->type = new TypeData( TypeData::Qualified ); 265 newnode->type->qualified.parent = parent->type; 266 newnode->type->qualified.child = child->type; 267 parent->type = nullptr; 268 child->type = nullptr; 269 delete parent; 270 delete child; 271 return newnode; 272 } 273 256 274 DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) { 257 275 assert( name ); … … 504 522 505 523 static void addQualifiersToType( TypeData *&src, TypeData * dst ) { 524 if ( src->forall && dst->kind == TypeData::Function ) { 525 if ( dst->forall ) { 526 dst->forall->appendList( src->forall ); 527 } else { 528 dst->forall = src->forall; 529 } // if 530 src->forall = nullptr; 531 } // if 506 532 if ( dst->base ) { 507 533 addQualifiersToType( src, dst->base ); … … 985 1011 try { 986 1012 Declaration * decl = cur->build(); 987 if ( decl ) {988 if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * >( decl ) ) {989 dwt->location = cur->location;990 * out++ = dwt;991 } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) {992 StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->get_name() );993 auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr);994 obj->location = cur->location;995 * out++ = obj;996 delete agg;997 } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) {998 UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->get_name() );999 auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr);1000 obj->location = cur->location;1001 * out++ = obj;1002 } // if1013 assert( decl ); 1014 if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * >( decl ) ) { 1015 dwt->location = cur->location; 1016 * out++ = dwt; 1017 } else if ( StructDecl * agg = dynamic_cast< StructDecl * >( decl ) ) { 1018 // xxx - this might be where anonymous struct members are added - should be conditional on struct name 1019 StructInstType * inst = new StructInstType( Type::Qualifiers(), agg->name ); 1020 auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr ); 1021 obj->location = cur->location; 1022 * out++ = obj; 1023 delete agg; 1024 } else if ( UnionDecl * agg = dynamic_cast< UnionDecl * >( decl ) ) { 1025 UnionInstType * inst = new UnionInstType( Type::Qualifiers(), agg->name ); 1026 auto obj = new ObjectDecl( "", Type::StorageClasses(), linkage, nullptr, inst, nullptr ); 1027 obj->location = cur->location; 1028 * out++ = obj; 1003 1029 } // if 1004 1030 } catch( SemanticErrorException &e ) { … … 1056 1082 if ( type->kind != TypeData::Function && funcSpecs.any() ) { 1057 1083 SemanticError( this, "invalid function specifier for " ); 1058 } // if1059 // Forall qualifier can only appear on a function/aggregate definition/declaration.1060 //1061 // forall int f(); // allowed1062 // forall int g( int i ); // allowed1063 // forall int i; // disallowed1064 if ( type->kind != TypeData::Function && type->forall ) {1065 SemanticError( this, "invalid type qualifier for " );1066 1084 } // if 1067 1085 bool isDelete = initializer && initializer->get_isDelete();
Note:
See TracChangeset
for help on using the changeset viewer.