Changeset 94e0864d for src/Parser/DeclarationNode.cc
- Timestamp:
- Jun 24, 2015, 4:12:31 PM (10 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, string, with_gc
- Children:
- 1869adf
- Parents:
- 94b4364 (diff), de62360d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r94b4364 r94e0864d 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Jun 13 08:02:03201513 // Update Count : 5812 // Last Modified On : Wed Jun 24 15:29:19 2015 13 // Update Count : 86 14 14 // 15 15 … … 24 24 #include "SynTree/Declaration.h" 25 25 #include "SynTree/Expression.h" 26 27 #include "Parser.h" 28 #include "TypedefTable.h" 29 extern TypedefTable typedefTable; 26 30 27 31 using namespace std; … … 177 181 newnode->type->aggregate->name = DeclarationNode::anonymous.newName(); 178 182 } // if 183 184 // SKULLDUGGERY: generate a typedef for the aggregate name so that the aggregate does not have to be qualified by 185 // "struct" 186 typedefTable.addToEnclosingScope( newnode->type->aggregate->name, TypedefTable::TD ); 187 DeclarationNode *typedf = new DeclarationNode; 188 typedf->name = newnode->type->aggregate->name; 189 newnode->appendList( typedf->addType( newnode->clone() )->addTypedef() ); 190 179 191 newnode->type->aggregate->params = formals; 180 192 newnode->type->aggregate->actuals = actuals; … … 191 203 newnode->type->enumeration->name = DeclarationNode::anonymous.newName(); 192 204 } // if 205 206 // SKULLDUGGERY: generate a typedef for the enumeration name so that the enumeration does not have to be qualified 207 // by "enum" 208 typedefTable.addToEnclosingScope( newnode->type->enumeration->name, TypedefTable::TD ); 209 DeclarationNode *typedf = new DeclarationNode; 210 typedf->name = newnode->type->enumeration->name; 211 newnode->appendList( typedf->addType( newnode->clone() )->addTypedef() ); 212 193 213 newnode->type->enumeration->constants = constants; 194 214 return newnode; … … 832 852 Declaration *DeclarationNode::build() const { 833 853 if ( type ) { 834 Declaration *newDecl = type->buildDecl( name, buildStorageClass(), maybeBuild< Expression >( bitfieldWidth ), build Inline(), linkage, maybeBuild< Initializer >(initializer) );854 Declaration *newDecl = type->buildDecl( name, buildStorageClass(), maybeBuild< Expression >( bitfieldWidth ), buildFuncSpecifier( Inline ), buildFuncSpecifier( Noreturn ), linkage, maybeBuild< Initializer >(initializer) ); 835 855 return newDecl; 836 856 } // if 837 if ( ! build Inline() ) {857 if ( ! buildFuncSpecifier( Inline ) && ! buildFuncSpecifier( Noreturn ) ) { 838 858 return new ObjectDecl( name, buildStorageClass(), linkage, maybeBuild< Expression >( bitfieldWidth ), 0, maybeBuild< Initializer >( initializer ) ); 839 859 } // if 840 throw SemanticError( "invalid inline specificationin declaration of ", this );860 throw SemanticError( "invalid function specifier in declaration of ", this ); 841 861 } 842 862 … … 879 899 for ( std::list< DeclarationNode::StorageClass >::const_iterator i = storageClasses.begin(); i != storageClasses.end(); ++i ) { 880 900 if ( *i == DeclarationNode::Inline || *i == DeclarationNode::Noreturn ) continue; // ignore function specifiers 881 882 901 if ( ret != DeclarationNode::NoStorageClass ) { // already have a valid storage class ? 883 902 throw SemanticError( "invalid combination of storage classes in declaration of ", this ); … … 888 907 } 889 908 890 bool DeclarationNode::build Inline() const {891 std::list< DeclarationNode::StorageClass >::const_iterator first = std::find( storageClasses.begin(), storageClasses.end(), DeclarationNode::Inline);892 if ( first == storageClasses.end() ) return false; 893 std::list< DeclarationNode::StorageClass >::const_iterator next = std::find( ++first, storageClasses.end(), DeclarationNode::Inline );894 if ( next == storageClasses.end() ) return true;895 throw SemanticError( "duplicate inline specificationin declaration of ", this );909 bool DeclarationNode::buildFuncSpecifier( DeclarationNode::StorageClass key ) const { 910 std::list< DeclarationNode::StorageClass >::const_iterator first = std::find( storageClasses.begin(), storageClasses.end(), key ); 911 if ( first == storageClasses.end() ) return false; // not found 912 first = std::find( ++first, storageClasses.end(), key ); // found 913 if ( first == storageClasses.end() ) return true; // not found again 914 throw SemanticError( "duplicate function specifier in declaration of ", this ); 896 915 } 897 916
Note:
See TracChangeset
for help on using the changeset viewer.