Changes in src/Parser/DeclarationNode.cc [c194661:284da8c]
- File:
-
- 1 edited
-
src/Parser/DeclarationNode.cc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
rc194661 r284da8c 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Jun 7 12:08:55201813 // Update Count : 10 7912 // Last Modified On : Fri Jul 6 06:56:08 2018 13 // Update Count : 1088 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 274 256 DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) { 275 257 assert( name ); … … 522 504 523 505 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 } // if530 src->forall = nullptr;531 } // if532 506 if ( dst->base ) { 533 507 addQualifiersToType( src, dst->base ); … … 1011 985 try { 1012 986 Declaration * decl = cur->build(); 1013 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 name1019 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;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 } // if 1029 1003 } // if 1030 1004 } catch( SemanticErrorException &e ) { … … 1082 1056 if ( type->kind != TypeData::Function && funcSpecs.any() ) { 1083 1057 SemanticError( this, "invalid function specifier for " ); 1058 } // if 1059 // Forall qualifier can only appear on a function/aggregate definition/declaration. 1060 // 1061 // forall int f(); // allowed 1062 // forall int g( int i ); // allowed 1063 // forall int i; // disallowed 1064 if ( type->kind != TypeData::Function && type->forall ) { 1065 SemanticError( this, "invalid type qualifier for " ); 1084 1066 } // if 1085 1067 bool isDelete = initializer && initializer->get_isDelete();
Note:
See TracChangeset
for help on using the changeset viewer.