Changes in src/Parser/DeclarationNode.cc [de62360d:68cd1ce]
- File:
-
- 1 edited
-
src/Parser/DeclarationNode.cc (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
rde62360d r68cd1ce 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Jun 24 15:29:19201513 // Update Count : 8612 // Last Modified On : Sat Jun 13 08:02:03 2015 13 // Update Count : 58 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;30 26 31 27 using namespace std; … … 181 177 newnode->type->aggregate->name = DeclarationNode::anonymous.newName(); 182 178 } // if 183 184 // SKULLDUGGERY: generate a typedef for the aggregate name so that the aggregate does not have to be qualified by185 // "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 191 179 newnode->type->aggregate->params = formals; 192 180 newnode->type->aggregate->actuals = actuals; … … 203 191 newnode->type->enumeration->name = DeclarationNode::anonymous.newName(); 204 192 } // if 205 206 // SKULLDUGGERY: generate a typedef for the enumeration name so that the enumeration does not have to be qualified207 // 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 213 193 newnode->type->enumeration->constants = constants; 214 194 return newnode; … … 852 832 Declaration *DeclarationNode::build() const { 853 833 if ( type ) { 854 Declaration *newDecl = type->buildDecl( name, buildStorageClass(), maybeBuild< Expression >( bitfieldWidth ), build FuncSpecifier( Inline ), buildFuncSpecifier( Noreturn), linkage, maybeBuild< Initializer >(initializer) );834 Declaration *newDecl = type->buildDecl( name, buildStorageClass(), maybeBuild< Expression >( bitfieldWidth ), buildInline(), linkage, maybeBuild< Initializer >(initializer) ); 855 835 return newDecl; 856 836 } // if 857 if ( ! build FuncSpecifier( Inline ) && ! buildFuncSpecifier( Noreturn) ) {837 if ( ! buildInline() ) { 858 838 return new ObjectDecl( name, buildStorageClass(), linkage, maybeBuild< Expression >( bitfieldWidth ), 0, maybeBuild< Initializer >( initializer ) ); 859 839 } // if 860 throw SemanticError( "invalid function specifierin declaration of ", this );840 throw SemanticError( "invalid inline specification in declaration of ", this ); 861 841 } 862 842 … … 899 879 for ( std::list< DeclarationNode::StorageClass >::const_iterator i = storageClasses.begin(); i != storageClasses.end(); ++i ) { 900 880 if ( *i == DeclarationNode::Inline || *i == DeclarationNode::Noreturn ) continue; // ignore function specifiers 881 901 882 if ( ret != DeclarationNode::NoStorageClass ) { // already have a valid storage class ? 902 883 throw SemanticError( "invalid combination of storage classes in declaration of ", this ); … … 907 888 } 908 889 909 bool DeclarationNode::build FuncSpecifier( 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 found912 first = std::find( ++first, storageClasses.end(), key ); // found913 if ( first == storageClasses.end() ) return true; // not found again914 throw SemanticError( "duplicate function specifierin declaration of ", this );890 bool DeclarationNode::buildInline() 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 specification in declaration of ", this ); 915 896 } 916 897
Note:
See TracChangeset
for help on using the changeset viewer.