Changes in src/SymTab/Validate.cc [cbce272:d24d4e1]
- File:
-
- 1 edited
-
src/SymTab/Validate.cc (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
rcbce272 rd24d4e1 9 9 // Author : Richard C. Bilson 10 10 // Created On : Sun May 17 21:50:04 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : T us Aug 8 13:27:00201713 // Update Count : 35 811 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 30 16:50:13 2017 13 // Update Count : 357 14 14 // 15 15 … … 38 38 // definition occurs later in the input. 39 39 40 #include <algorithm> 41 #include <iterator> 42 #include <list> 43 44 #include "CodeGen/CodeGenerator.h" 45 46 #include "Common/PassVisitor.h" 47 #include "Common/ScopedMap.h" 48 #include "Common/UniqueName.h" 49 #include "Common/utility.h" 50 51 #include "Concurrency/Keywords.h" 52 53 #include "GenPoly/DeclMutator.h" 54 55 #include "InitTweak/InitTweak.h" 56 57 #include "AddVisit.h" 58 #include "Autogen.h" 59 #include "FixFunction.h" 60 // #include "ImplementationType.h" 61 #include "Indexer.h" 62 #include "MakeLibCfa.h" 63 #include "TypeEquality.h" 40 64 #include "Validate.h" 41 65 42 #include <cstddef> // for size_t 43 #include <algorithm> // for move, transform 44 #include <cassert> // for safe_dynamic_cast, assertf 45 #include <iterator> // for back_inserter, inserter, back_... 46 #include <list> // for list, _List_iterator, list<>::... 47 #include <map> // for _Rb_tree_iterator, map, map<>:... 48 #include <memory> // for unique_ptr, allocator 49 #include <string> // for string, operator+, operator== 50 #include <tuple> // for get 51 #include <utility> // for pair, make_pair 52 53 #include "AddVisit.h" // for addVisit 54 #include "Autogen.h" // for SizeType, autogenerateRoutines 55 #include "CodeGen/CodeGenerator.h" // for genName 56 #include "Common/PassVisitor.h" // for PassVisitor, WithDeclsToAdd 57 #include "Common/ScopedMap.h" // for ScopedMap<>::const_iterator 58 #include "Common/SemanticError.h" // for SemanticError 59 #include "Common/UniqueName.h" // for UniqueName 60 #include "Common/utility.h" // for operator+, cloneAll, deleteAll 61 #include "Concurrency/Keywords.h" // for applyKeywords, implementMutexF... 62 #include "FixFunction.h" // for FixFunction 63 #include "Indexer.h" // for Indexer 64 #include "InitTweak/InitTweak.h" // for isCtorDtor, isCtorDtorAssign 65 #include "Parser/LinkageSpec.h" // for C, Cforall 66 #include "ResolvExpr/typeops.h" // for extractResultType, typesCompat... 67 #include "SynTree/Attribute.h" // for Attribute 68 #include "SynTree/Constant.h" // for Constant 69 #include "SynTree/Declaration.h" // for EnumDecl, StructDecl, UnionDecl 70 #include "SynTree/Expression.h" // for TypeExpr, CompoundLiteralExpr 71 #include "SynTree/Initializer.h" // for ListInit, Initializer, noDesig... 72 #include "SynTree/Mutator.h" // for mutateAll, Mutator 73 #include "SynTree/Statement.h" // for CompoundStmt, DeclStmt, Return... 74 #include "SynTree/Type.h" // for Type, TypeInstType, TraitInstType 75 #include "SynTree/TypeSubstitution.h" // for TypeSubstitution, applySubstit... 76 #include "SynTree/Visitor.h" // for acceptAll, Visitor 66 #include "ResolvExpr/typeops.h" 67 68 #include "SynTree/Attribute.h" 69 #include "SynTree/Expression.h" 70 #include "SynTree/Mutator.h" 71 #include "SynTree/Statement.h" 72 #include "SynTree/Type.h" 73 #include "SynTree/TypeSubstitution.h" 74 #include "SynTree/Visitor.h" 77 75 78 76 #define debugPrint( x ) if ( doDebug ) { std::cout << x; } … … 607 605 // a return statement in a void-returning function in C. The expression is treated as if it 608 606 // were cast to void. 609 if ( ! returnStmt->get_expr()&& returnVals.size() != 0 ) {607 if ( returnStmt->get_expr() == NULL && returnVals.size() != 0 ) { 610 608 throw SemanticError( "Non-void function returns no values: " , returnStmt ); 611 609 } … … 686 684 Type *designatorType = tyDecl->get_base()->stripDeclarator(); 687 685 if ( StructInstType *aggDecl = dynamic_cast< StructInstType * >( designatorType ) ) { 688 return new StructDecl( aggDecl->get_name() , DeclarationNode::Struct, noAttributes, tyDecl->get_linkage());686 return new StructDecl( aggDecl->get_name() ); 689 687 } else if ( UnionInstType *aggDecl = dynamic_cast< UnionInstType * >( designatorType ) ) { 690 return new UnionDecl( aggDecl->get_name() , noAttributes, tyDecl->get_linkage());688 return new UnionDecl( aggDecl->get_name() ); 691 689 } else if ( EnumInstType *enumDecl = dynamic_cast< EnumInstType * >( designatorType ) ) { 692 return new EnumDecl( enumDecl->get_name() , noAttributes, tyDecl->get_linkage());690 return new EnumDecl( enumDecl->get_name() ); 693 691 } else { 694 692 return ret->clone(); … … 783 781 type = new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() ); 784 782 } // if 785 TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), Type::StorageClasses(), type , aggDecl->get_linkage()) );783 TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), Type::StorageClasses(), type ) ); 786 784 typedefNames[ aggDecl->get_name() ] = std::make_pair( std::move( tyDecl ), scopeLevel ); 787 785 } // if … … 838 836 void validateGeneric( Aggr * inst ) { 839 837 std::list< TypeDecl * > * params = inst->get_baseParameters(); 840 if ( params ) {838 if ( params != NULL ) { 841 839 std::list< Expression * > & args = inst->get_parameters(); 842 840 … … 903 901 FunctionType * ftype = functionDecl->get_functionType(); 904 902 std::list< DeclarationWithType * > & retVals = ftype->get_returnVals(); 905 assertf( retVals.size() == 0 || retVals.size() == 1, "Function %s has too many return values: % zu", functionDecl->get_name().c_str(), retVals.size() );903 assertf( retVals.size() == 0 || retVals.size() == 1, "Function %s has too many return values: %d", functionDecl->get_name().c_str(), retVals.size() ); 906 904 if ( retVals.size() == 1 ) { 907 905 // ensure all function return values have a name - use the name of the function to disambiguate (this also provides a nice bit of help for debugging). … … 939 937 void ArrayLength::previsit( ObjectDecl * objDecl ) { 940 938 if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->get_type() ) ) { 941 if ( at->get_dimension() ) return;939 if ( at->get_dimension() != nullptr ) return; 942 940 if ( ListInit * init = dynamic_cast< ListInit * >( objDecl->get_init() ) ) { 943 941 at->set_dimension( new ConstantExpr( Constant::from_ulong( init->get_initializers().size() ) ) );
Note:
See TracChangeset
for help on using the changeset viewer.