Ignore:
Timestamp:
Aug 11, 2017, 10:33:37 AM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
54cd58b0
Parents:
3d4b23fa (diff), 59a75cb (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Validate.cc

    r3d4b23fa r0720e049  
    99// Author           : Richard C. Bilson
    1010// Created On       : Sun May 17 21:50:04 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 30 16:50:13 2017
    13 // Update Count     : 357
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Tus Aug  8 13:27:00 2017
     13// Update Count     : 358
    1414//
    1515
     
    3838//   definition occurs later in the input.
    3939
    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"
    6440#include "Validate.h"
    6541
    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"
     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
    7577
    7678#define debugPrint( x ) if ( doDebug ) { std::cout << x; }
     
    605607                // a return statement in a void-returning function in C. The expression is treated as if it
    606608                // were cast to void.
    607                 if ( returnStmt->get_expr() == NULL && returnVals.size() != 0 ) {
     609                if ( ! returnStmt->get_expr() && returnVals.size() != 0 ) {
    608610                        throw SemanticError( "Non-void function returns no values: " , returnStmt );
    609611                }
     
    684686                Type *designatorType = tyDecl->get_base()->stripDeclarator();
    685687                if ( StructInstType *aggDecl = dynamic_cast< StructInstType * >( designatorType ) ) {
    686                         return new StructDecl( aggDecl->get_name() );
     688                        return new StructDecl( aggDecl->get_name(), DeclarationNode::Struct, noAttributes, tyDecl->get_linkage() );
    687689                } else if ( UnionInstType *aggDecl = dynamic_cast< UnionInstType * >( designatorType ) ) {
    688                         return new UnionDecl( aggDecl->get_name() );
     690                        return new UnionDecl( aggDecl->get_name(), noAttributes, tyDecl->get_linkage() );
    689691                } else if ( EnumInstType *enumDecl = dynamic_cast< EnumInstType * >( designatorType ) ) {
    690                         return new EnumDecl( enumDecl->get_name() );
     692                        return new EnumDecl( enumDecl->get_name(), noAttributes, tyDecl->get_linkage() );
    691693                } else {
    692694                        return ret->clone();
     
    781783                                type = new EnumInstType( Type::Qualifiers(), newDeclEnumDecl->get_name() );
    782784                        } // if
    783                         TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), Type::StorageClasses(), type ) );
     785                        TypedefDeclPtr tyDecl( new TypedefDecl( aggDecl->get_name(), Type::StorageClasses(), type, aggDecl->get_linkage() ) );
    784786                        typedefNames[ aggDecl->get_name() ] = std::make_pair( std::move( tyDecl ), scopeLevel );
    785787                } // if
     
    836838        void validateGeneric( Aggr * inst ) {
    837839                std::list< TypeDecl * > * params = inst->get_baseParameters();
    838                 if ( params != NULL ) {
     840                if ( params ) {
    839841                        std::list< Expression * > & args = inst->get_parameters();
    840842
     
    901903                FunctionType * ftype = functionDecl->get_functionType();
    902904                std::list< DeclarationWithType * > & retVals = ftype->get_returnVals();
    903                 assertf( retVals.size() == 0 || retVals.size() == 1, "Function %s has too many return values: %d", functionDecl->get_name().c_str(), retVals.size() );
     905                assertf( retVals.size() == 0 || retVals.size() == 1, "Function %s has too many return values: %zu", functionDecl->get_name().c_str(), retVals.size() );
    904906                if ( retVals.size() == 1 ) {
    905907                        // 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).
     
    937939        void ArrayLength::previsit( ObjectDecl * objDecl ) {
    938940                if ( ArrayType * at = dynamic_cast< ArrayType * >( objDecl->get_type() ) ) {
    939                         if ( at->get_dimension() != nullptr ) return;
     941                        if ( at->get_dimension() ) return;
    940942                        if ( ListInit * init = dynamic_cast< ListInit * >( objDecl->get_init() ) ) {
    941943                                at->set_dimension( new ConstantExpr( Constant::from_ulong( init->get_initializers().size() ) ) );
Note: See TracChangeset for help on using the changeset viewer.