Ignore:
Timestamp:
Oct 19, 2017, 12:01:04 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
837ce06
Parents:
b96ec83 (diff), a15b72c (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' into cleanup-dtors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/TypeData.cc

    rb96ec83 r6840e7c  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Sep  1 23:13:38 2017
    13 // Update Count     : 569
     12// Last Modified On : Mon Sep 25 18:33:41 2017
     13// Update Count     : 587
    1414//
    1515
     
    9898} // TypeData::TypeData
    9999
     100
    100101TypeData::~TypeData() {
    101102        delete base;
     
    161162        } // switch
    162163} // TypeData::~TypeData
     164
    163165
    164166TypeData * TypeData::clone() const {
     
    235237} // TypeData::clone
    236238
     239
    237240void TypeData::print( ostream &os, int indent ) const {
    238241        for ( int i = 0; i < Type::NumTypeQualifier; i += 1 ) {
     
    398401        } // switch
    399402} // TypeData::print
     403
    400404
    401405template< typename ForallList >
     
    430434                } // if
    431435        } // for
    432 }
     436} // buildForall
     437
    433438
    434439Type * typebuild( const TypeData * td ) {
     
    477482} // typebuild
    478483
     484
    479485TypeData * typeextractAggregate( const TypeData * td, bool toplevel ) {
    480486        TypeData * ret = nullptr;
     
    504510} // typeextractAggregate
    505511
     512
    506513Type::Qualifiers buildQualifiers( const TypeData * td ) {
    507514        return td->qualifiers;
    508515} // buildQualifiers
    509516
     517
     518static string genTSError( string msg, DeclarationNode::BasicType basictype ) {
     519        throw SemanticError( string( "invalid type specifier \"" ) + msg + "\" for type \"" + DeclarationNode::basicTypeNames[basictype] + "\"." );
     520} // genTSError
     521
    510522Type * buildBasicType( const TypeData * td ) {
    511523        BasicType::Kind ret;
     
    513525        switch ( td->basictype ) {
    514526          case DeclarationNode::Void:
    515                 if ( td->signedness != DeclarationNode::NoSignedness && td->length != DeclarationNode::NoLength ) {
    516                         throw SemanticError( "invalid type specifier \"void\" in type: ", td );
    517                 } // if
    518 
     527                if ( td->signedness != DeclarationNode::NoSignedness ) {
     528                        genTSError( DeclarationNode::signednessNames[ td->signedness ], td->basictype );
     529                } // if
     530                if ( td->length != DeclarationNode::NoLength ) {
     531                        genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype );
     532                } // if
    519533                return new VoidType( buildQualifiers( td ) );
    520534                break;
     
    522536          case DeclarationNode::Bool:
    523537                if ( td->signedness != DeclarationNode::NoSignedness ) {
    524                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessNames[ td->signedness ] + " in type: ", td );
     538                        genTSError( DeclarationNode::signednessNames[ td->signedness ], td->basictype );
    525539                } // if
    526540                if ( td->length != DeclarationNode::NoLength ) {
    527                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td );
     541                        genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype );
    528542                } // if
    529543
     
    538552
    539553                if ( td->length != DeclarationNode::NoLength ) {
    540                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td );
     554                        genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype );
    541555                } // if
    542556
     
    557571                break;
    558572
     573          case DeclarationNode::Int128:
     574                ret = td->signedness == 1 ? BasicType::UnsignedInt128 : BasicType::SignedInt128;
     575                if ( td->length != DeclarationNode::NoLength ) {
     576                        genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype );
     577                } // if
     578                break;
     579
    559580          case DeclarationNode::Float:
     581          case DeclarationNode::Float80:
     582          case DeclarationNode::Float128:
    560583          case DeclarationNode::Double:
    561584          case DeclarationNode::LongDouble:                                     // not set until below
     
    568591          FloatingPoint: ;
    569592                if ( td->signedness != DeclarationNode::NoSignedness ) {
    570                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::signednessNames[ td->signedness ] + " in type: ", td );
     593                        genTSError( DeclarationNode::signednessNames[ td->signedness ], td->basictype );
    571594                } // if
    572595                if ( td->length == DeclarationNode::Short || td->length == DeclarationNode::LongLong ) {
    573                         throw SemanticError( string( "invalid type specifier " ) + DeclarationNode::lengthNames[ td->length ] + " in type: ", td );
     596                        genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype );
    574597                } // if
    575598                if ( td->basictype == DeclarationNode::Float && td->length == DeclarationNode::Long ) {
    576                         throw SemanticError( "invalid type specifier \"long\" in type: ", td );
     599                        genTSError( DeclarationNode::lengthNames[ td->length ], td->basictype );
    577600                } // if
    578601                if ( td->length == DeclarationNode::Long ) {
     
    593616                goto Integral;
    594617          default:
    595                 assert(false);
     618                assertf( false, "unknown basic type" );
    596619                return nullptr;
    597620        } // switch
     
    601624        return bt;
    602625} // buildBasicType
     626
    603627
    604628PointerType * buildPointer( const TypeData * td ) {
     
    612636        return pt;
    613637} // buildPointer
     638
    614639
    615640ArrayType * buildArray( const TypeData * td ) {
     
    626651} // buildArray
    627652
     653
    628654ReferenceType * buildReference( const TypeData * td ) {
    629655        ReferenceType * rt;
     
    637663} // buildReference
    638664
     665
    639666AggregateDecl * buildAggregate( const TypeData * td, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) {
    640667        assert( td->kind == TypeData::Aggregate );
     
    665692        return at;
    666693} // buildAggregate
     694
    667695
    668696ReferenceToType * buildComAggInst( const TypeData * type, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) {
     
    722750} // buildAggInst
    723751
     752
    724753ReferenceToType * buildAggInst( const TypeData * td ) {
    725754        assert( td->kind == TypeData::AggregateInst );
     
    761790} // buildAggInst
    762791
     792
    763793NamedTypeDecl * buildSymbolic( const TypeData * td, const string & name, Type::StorageClasses scs, LinkageSpec::Spec linkage ) {
    764794        assert( td->kind == TypeData::Symbolic );
     
    775805} // buildSymbolic
    776806
     807
    777808EnumDecl * buildEnum( const TypeData * td, std::list< Attribute * > attributes, LinkageSpec::Spec linkage ) {
    778809        assert( td->kind == TypeData::Enum );
     
    790821} // buildEnum
    791822
     823
    792824TypeInstType * buildSymbolicInst( const TypeData * td ) {
    793825        assert( td->kind == TypeData::SymbolicInst );
     
    797829        return ret;
    798830} // buildSymbolicInst
     831
    799832
    800833TupleType * buildTuple( const TypeData * td ) {
     
    807840} // buildTuple
    808841
     842
    809843TypeofType * buildTypeof( const TypeData * td ) {
    810844        assert( td->kind == TypeData::Typeof );
     
    813847        return new TypeofType( buildQualifiers( td ), td->typeexpr->build() );
    814848} // buildTypeof
     849
    815850
    816851Declaration * buildDecl( const TypeData * td, const string &name, Type::StorageClasses scs, Expression * bitfieldWidth, Type::FuncSpecifiers funcSpec, LinkageSpec::Spec linkage, Expression *asmName, Initializer * init, std::list< Attribute * > attributes ) {
     
    836871        return nullptr;
    837872} // buildDecl
     873
    838874
    839875FunctionType * buildFunction( const TypeData * td ) {
     
    857893        return ft;
    858894} // buildFunction
     895
    859896
    860897// Transform KR routine declarations into C99 routine declarations:
Note: See TracChangeset for help on using the changeset viewer.