Changes in src/Parser/DeclarationNode.cc [7d05e7e:28307be]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r7d05e7e r28307be 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Sep 9 23:21:47201613 // Update Count : 40212 // Last Modified On : Mon Aug 29 22:30:56 2016 13 // Update Count : 327 14 14 // 15 15 … … 43 43 extern LinkageSpec::Spec linkage; // defined in parser.yy 44 44 45 DeclarationNode::DeclarationNode() : 46 type( 0 ), 47 storageClass( NoStorageClass ), 48 isInline( false ), 49 isNoreturn( false ), 50 bitfieldWidth( 0 ), 51 initializer( 0 ), 52 hasEllipsis( false ), 53 linkage( ::linkage ), 54 extension( false ) { 45 DeclarationNode::DeclarationNode() 46 : type( 0 ) 47 , storageClass( NoStorageClass ) 48 , isInline( false ) 49 , isNoreturn( false ) 50 , bitfieldWidth( 0 ) 51 , initializer( 0 ) 52 , hasEllipsis( false ) 53 , linkage( ::linkage ) 54 , extension( false ) 55 , error() { 56 attr.expr = nullptr; 57 attr.type = nullptr; 58 55 59 variable.tyClass = DeclarationNode::Type; 56 60 variable.assertions = nullptr; 57 58 attr.expr = nullptr;59 attr.type = nullptr;60 61 } 61 62 … … 392 393 393 394 if ( (qsrc & qdst).any() ) { // common bits between qualifier masks ? 394 for ( int i = 0; i < NoOfQualifier; i += 1 ) { // find common qualifiers 395 if ( qsrc[i] & qdst[i] ) { 396 error += string(error.empty() ? "" : ", ") + "duplicate " + DeclarationNode::qualifierName[i]; 395 error = "duplicate qualifier "; 396 int j = 0; // separator detector 397 for ( int i = 0; i < DeclarationNode::NoOfQualifier; i += 1 ) { 398 if ( qsrc[i] & qdst[i] ) { // find specific qualifiers in common 399 if ( j > 0 ) error += ", "; 400 error += DeclarationNode::qualifierName[i]; 401 j += 1; 397 402 } // if 398 403 } // for 404 error += " in declaration of "; 399 405 } // if 400 406 } // DeclarationNode::checkQualifiers … … 436 442 storageClass = q->storageClass; 437 443 } else if ( q->storageClass != NoStorageClass ) { 438 if ( storageClass == q->storageClass ) { 439 q->error += string( "duplicate " ) + storageName[ storageClass ]; 440 } else { // can only have one storage class 441 q->error += string( "multiple " ) + storageName[ storageClass ] + " & " + storageName[ q->storageClass ]; 442 } // if 443 } // if 444 if ( ! q->error.empty() ) { 445 error += (! error.empty() ? ", " : "") + q->error; 446 } // if 447 return this; 448 } // DeclarationNode::copyStorageClasses 444 q->error = "invalid combination of storage classes in declaration of "; 445 } // if 446 if ( error.empty() ) error = q->error; 447 return this; 448 } 449 449 450 450 static void addTypeToType( TypeData *&src, TypeData *&dst ) { … … 908 908 909 909 Declaration *DeclarationNode::build() const { 910 if ( ! error.empty() ) throw SemanticError( error + " in declaration of ", this );910 if ( ! error.empty() ) throw SemanticError( error, this ); 911 911 if ( type ) { 912 912 if ( type->kind == TypeData::Variable ) { … … 922 922 return (new ObjectDecl( name, storageClass, linkage, maybeBuild< Expression >( bitfieldWidth ), 0, maybeBuild< Initializer >( initializer ) ))->set_extension( extension ); 923 923 } // if 924 throw SemanticError( "invalid function specifier ", this );924 throw SemanticError( "invalid function specifier in declaration of ", this ); 925 925 } 926 926 … … 971 971 } 972 972 973 // DeclarationNode::StorageClass DeclarationNode::buildStorageClass() const { 974 // DeclarationNode::StorageClass ret = DeclarationNode::NoStorageClass; 975 // for ( std::list< DeclarationNode::StorageClass >::const_iterator i = storageClasses.begin(); i != storageClasses.end(); ++i ) { 976 // if ( *i == DeclarationNode::Inline || *i == DeclarationNode::Noreturn ) continue; // ignore function specifiers 977 // if ( ret != DeclarationNode::NoStorageClass ) { // already have a valid storage class ? 978 // throw SemanticError( "invalid combination of storage classes in declaration of ", this ); 979 // } // if 980 // ret = *i; 981 // } // for 982 // return ret; 983 // } 984 985 // bool DeclarationNode::buildFuncSpecifier( DeclarationNode::StorageClass key ) const { 986 // std::list< DeclarationNode::StorageClass >::const_iterator first = std::find( storageClasses.begin(), storageClasses.end(), key ); 987 // if ( first == storageClasses.end() ) return false; // not found 988 // first = std::find( ++first, storageClasses.end(), key ); // found 989 // if ( first == storageClasses.end() ) return true; // not found again 990 // throw SemanticError( "duplicate function specifier in declaration of ", this ); 991 // } 992 973 993 // Local Variables: // 974 994 // tab-width: 4 //
Note:
See TracChangeset
for help on using the changeset viewer.