Changeset 4e24610 for src/SynTree
- Timestamp:
- May 6, 2016, 1:56:08 PM (9 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:
- d029162e
- Parents:
- 711eee5
- Location:
- src/SynTree
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Declaration.h
r711eee5 r4e24610 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Declaration.h -- 7 // Declaration.h -- 8 8 // 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Peter A. Buhr12 // Last Modified On : Wed Mar 2 17:28:11201611 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri May 06 11:16:45 2016 13 13 // Update Count : 33 14 14 // … … 106 106 typedef DeclarationWithType Parent; 107 107 public: 108 FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn ); 108 // temporary - merge this into general GCC attributes 109 enum Attribute { 110 NoAttribute, Constructor, Destructor, 111 }; 112 113 FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, Attribute attribute = NoAttribute ); 109 114 FunctionDecl( const FunctionDecl &other ); 110 115 virtual ~FunctionDecl(); … … 119 124 std::list< std::string >& get_oldIdents() { return oldIdents; } 120 125 std::list< Declaration* >& get_oldDecls() { return oldDecls; } 126 Attribute get_attribute() const { return attribute; } 127 void set_attribute( Attribute newValue ) { attribute = newValue; } 121 128 122 129 virtual FunctionDecl *clone() const { return new FunctionDecl( *this ); } … … 130 137 std::list< std::string > oldIdents; 131 138 std::list< Declaration* > oldDecls; 139 Attribute attribute; 132 140 }; 133 141 -
src/SynTree/FunctionDecl.cc
r711eee5 r4e24610 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Fri Apr 01 11:40:07201612 // Last Modified On : Fri May 06 11:35:09 2016 13 13 // Update Count : 19 14 14 // … … 21 21 #include "Common/utility.h" 22 22 23 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn )24 : Parent( name, sc, linkage ), type( type ), statements( statements ) {23 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClass sc, LinkageSpec::Type linkage, FunctionType *type, CompoundStmt *statements, bool isInline, bool isNoreturn, Attribute attribute ) 24 : Parent( name, sc, linkage ), type( type ), statements( statements ), attribute( attribute ) { 25 25 set_isInline( isInline ); 26 26 set_isNoreturn( isNoreturn ); 27 // this is a brazen hack to force the function "main" to have C linkage 28 if ( name == "main" ) { 29 set_linkage( LinkageSpec::C ); 30 } // if 27 31 } 28 32 29 33 FunctionDecl::FunctionDecl( const FunctionDecl &other ) 30 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ) {34 : Parent( other ), type( maybeClone( other.type ) ), statements( maybeClone( other.statements ) ), attribute( other.attribute ) { 31 35 } 32 36 … … 61 65 os << "_Noreturn "; 62 66 } // if 67 switch ( attribute ) { 68 case Constructor: 69 os << "Global Constructor "; 70 break; 71 case Destructor: 72 os << "Global Destructor "; 73 break; 74 default: 75 break; 76 } 63 77 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 64 78 os << DeclarationNode::storageName[ get_storageClass() ] << ' '; … … 100 114 os << "_Noreturn "; 101 115 } // if 116 switch ( attribute ) { 117 case Constructor: 118 os << " Global Constructor "; 119 break; 120 case Destructor: 121 os << " Global Destructor "; 122 break; 123 default: 124 break; 125 } 102 126 if ( get_storageClass() != DeclarationNode::NoStorageClass ) { 103 127 os << DeclarationNode::storageName[ get_storageClass() ] << ' ';
Note: See TracChangeset
for help on using the changeset viewer.