Changeset 03e3117
- Timestamp:
- Sep 10, 2016, 11:04:50 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- add7117, d88f256a
- Parents:
- b6fe7e6 (diff), 126e54f (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. - Location:
- src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
rb6fe7e6 r03e3117 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 29 22:30:56201613 // Update Count : 32712 // Last Modified On : Fri Sep 9 23:21:47 2016 13 // Update Count : 402 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 ) 55 , error() { 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 variable.tyClass = DeclarationNode::Type; 56 variable.assertions = nullptr; 57 56 58 attr.expr = nullptr; 57 59 attr.type = nullptr; 58 59 variable.tyClass = DeclarationNode::Type;60 variable.assertions = nullptr;61 60 } 62 61 … … 393 392 394 393 if ( (qsrc & qdst).any() ) { // common bits between qualifier masks ? 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; 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]; 402 397 } // if 403 398 } // for 404 error += " in declaration of ";405 399 } // if 406 400 } // DeclarationNode::checkQualifiers … … 442 436 storageClass = q->storageClass; 443 437 } else if ( q->storageClass != NoStorageClass ) { 444 q->error = "invalid combination of storage classes in declaration of "; 445 } // if 446 if ( error.empty() ) error = q->error; 447 return this; 448 } 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 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 , this );910 if ( ! error.empty() ) throw SemanticError( error + " in declaration of ", 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 in declaration of", this );924 throw SemanticError( "invalid function specifier ", 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 specifiers977 // if ( ret != DeclarationNode::NoStorageClass ) { // already have a valid storage class ?978 // throw SemanticError( "invalid combination of storage classes in declaration of ", this );979 // } // if980 // ret = *i;981 // } // for982 // 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 found988 // first = std::find( ++first, storageClasses.end(), key ); // found989 // if ( first == storageClasses.end() ) return true; // not found again990 // throw SemanticError( "duplicate function specifier in declaration of ", this );991 // }992 993 973 // Local Variables: // 994 974 // tab-width: 4 // -
src/Parser/ParseNode.h
rb6fe7e6 r03e3117 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 29 21:45:43201613 // Update Count : 58 312 // Last Modified On : Thu Sep 8 21:58:06 2016 13 // Update Count : 587 14 14 // 15 15 … … 290 290 // bool buildFuncSpecifier( StorageClass key ) const; 291 291 292 struct Enumeration_t {293 std::string name;294 DeclarationNode * constants;295 };296 Enumeration_t enumeration;297 298 292 struct Variable_t { 299 293 DeclarationNode::TypeClass tyClass; … … 408 402 if ( result ) { 409 403 *out++ = result; 410 } else {411 404 } // if 412 405 } catch( SemanticError &e ) { -
src/Parser/TypeData.h
rb6fe7e6 r03e3117 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 29 22:31:52201613 // Update Count : 11 012 // Last Modified On : Fri Sep 9 23:20:55 2016 13 // Update Count : 117 14 14 // 15 15 … … 96 96 Array_t array; 97 97 Enumeration_t enumeration; 98 // Variable_t variable; 98 99 Function_t function; 99 100 Symbolic_t symbolic; 100 101 DeclarationNode * tuple; 101 102 ExpressionNode * typeexpr; 102 // Attr_t attr;103 // Attr_t attr; 103 104 // DeclarationNode::BuiltinType builtin; 104 105 -
src/tests/.expect/declarationErrors.txt
rb6fe7e6 r03e3117 1 1 CFA Version 1.0.0 (debug) 2 Error: invalid combination of storage classes in declaration of x9: static const volatile short int2 Error: duplicate static in declaration of x1: static const volatile short int 3 3 4 Error: invalid combination of storage classes in declaration of x18: static const volatile instance of const volatile struct __anonymous0 4 Error: multiple extern & static in declaration of x2: extern const volatile short int 5 6 Error: multiple extern & auto, multiple extern & static, multiple extern & static, duplicate extern in declaration of x3: extern const volatile short int 7 8 Error: duplicate static in declaration of x4: static const volatile instance of const volatile struct __anonymous0 5 9 with members 6 10 with body 7 11 8 12 9 Error: duplicate qualifier volatile in declaration of x19: static const volatile instance of const volatile struct __anonymous113 Error: duplicate const, duplicate static, duplicate volatile in declaration of x5: static const volatile instance of const volatile struct __anonymous1 10 14 with members 11 15 with body 12 16 13 17 14 Error: invalid combination of storage classes in declaration of x28: static const volatile instance of type Int18 Error: duplicate static in declaration of x6: static const volatile instance of type Int 15 19 16 Error: duplicate qualifierconst in declaration of f01: static inline function20 Error: duplicate const in declaration of f01: static inline function 17 21 with no parameters 18 22 returning const volatile int 19 23 20 24 21 Error: duplicate qualifiervolatile in declaration of f02: static inline function25 Error: duplicate volatile in declaration of f02: static inline function 22 26 with no parameters 23 27 returning const volatile int 24 28 25 29 26 Error: duplicate qualifierconst in declaration of f03: static inline function30 Error: duplicate const in declaration of f03: static inline function 27 31 with no parameters 28 32 returning const volatile int 29 33 30 34 31 Error: duplicate qualifiervolatile in declaration of f04: static inline function35 Error: duplicate volatile in declaration of f04: static inline function 32 36 with no parameters 33 37 returning const volatile int 34 38 35 39 36 Error: duplicate qualifierconst in declaration of f05: static inline function40 Error: duplicate const in declaration of f05: static inline function 37 41 with no parameters 38 42 returning const volatile int 39 43 40 44 41 Error: duplicate qualifiervolatile in declaration of f06: static inline function45 Error: duplicate volatile in declaration of f06: static inline function 42 46 with no parameters 43 47 returning const volatile int 44 48 45 49 46 Error: duplicate qualifierconst in declaration of f07: static inline function50 Error: duplicate const in declaration of f07: static inline function 47 51 with no parameters 48 52 returning const volatile int 49 53 50 54 51 Error: duplicate qualifier const,volatile in declaration of f08: static inline function55 Error: duplicate const, duplicate volatile in declaration of f08: static inline function 52 56 with no parameters 53 57 returning const volatile int 54 58 55 59 56 Error: duplicate qualifier const,volatile in declaration of f09: static inline function60 Error: duplicate const, duplicate volatile in declaration of f09: static inline function 57 61 with no parameters 58 62 returning const volatile int 59 63 60 64 61 Error: duplicate qualifier const,volatile in declaration of f09: static inline function65 Error: duplicate const, duplicate _Atomic, duplicate _Atomic, duplicate const, duplicate restrict, duplicate volatile in declaration of f09: static inline function 62 66 with no parameters 63 returning const volatileint67 returning const restrict volatile _Atomic int 64 68 65 69 -
src/tests/declarationErrors.c
rb6fe7e6 r03e3117 10 10 // Created On : Wed Aug 17 08:23:43 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Aug 25 18:16:40201613 // Update Count : 512 // Last Modified On : Fri Sep 9 22:57:52 2016 13 // Update Count : 31 14 14 // 15 15 16 static short int volatile static const x9; // duplicate static 17 struct { int i; } const static volatile static x18; // duplicate static 18 struct { int i; } const static volatile static volatile x19; // duplicate static & volatile 16 static short int volatile static const x1; // duplicate static 17 extern short int static volatile const x2; // multiple extern & static 18 extern short int auto static volatile static extern const x3; // duplicate and multiple storage classes 19 struct { int i; } const static volatile static x4; // duplicate static 20 struct { int i; } const static volatile const static volatile x5; // duplicate static & const & volatile 19 21 typedef int Int; 20 static Int volatile static const x 28; // duplicate static22 static Int volatile static const x6; // duplicate static 21 23 22 24 const static inline const volatile int f01(); // duplicate const … … 24 26 const inline const volatile int static f03(); // duplicate const 25 27 volatile inline static const volatile int f04(); // duplicate volatile 26 const static const inline volatile intf05(); // duplicate const27 volatile static const volatile inline intf06(); // duplicate volatile28 const static const volatile intinline f07(); // duplicate const29 volatile static const int inline const volatile f08(); 28 const static int const inline volatile f05(); // duplicate const 29 volatile int static const volatile inline f06(); // duplicate volatile 30 const static const int volatile inline f07(); // duplicate const 31 volatile static const int inline const volatile f08(); // duplicate volatile 30 32 31 volatile static const int inline const volatile f09(); 32 volatile static const int inline const volatile f09();// duplicate volatile33 volatile static const int inline const volatile f09(); // duplicate volatile 34 _Atomic _Atomic _Atomic volatile restrict static const const int inline restrict const volatile f09(); // duplicate volatile 33 35 34 36 //Dummy main -
src/tests/test.py
rb6fe7e6 r03e3117 285 285 # check if the user already passed in a number of jobs for multi-threading 286 286 make_flags = environ.get('MAKEFLAGS') 287 make_has_max_jobs = re.search("(-j|--jobs)\s*([0-9]+)", make_flags) if make_flags else None 288 make_max_jobs = make_has_max_jobs.group(2) if make_has_max_jobs else None 289 make_cmd = "make" if make_flags and "-j" in make_flags else "make -j8" 287 make_jobs_fds = re.search("--jobserver-fds=\s*([0-9]+),([0-9]+)", make_flags) if make_flags else None 288 if make_jobs_fds : 289 tokens = os.read(int(make_jobs_fds.group(1)), 1024) 290 options.jobs = len(tokens) 291 os.write(int(make_jobs_fds.group(2)), tokens) 290 292 291 293 # make sure we have a valid number of jobs that corresponds to user input 292 options.jobs = int(make_max_jobs) if make_max_jobs else (options.jobs if options.jobs else 1)293 294 if options.jobs <= 0 : 294 295 print('ERROR: Invalid number of jobs', file=sys.stderr) … … 296 297 297 298 print('Running on %i cores' % options.jobs) 299 make_cmd = "make" if make_flags else ("make -j%i" % options.jobs) 298 300 299 301 # users may want to simply list the tests
Note: See TracChangeset
for help on using the changeset viewer.