Changeset 1d17939


Ignore:
Timestamp:
Jul 29, 2020, 5:12:28 PM (15 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast, new-ast-unique-expr
Children:
b81fd95
Parents:
15806ed
Message:

Implemented the recomented fix for #204, added at test that would have failed without it.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/ConversionCost.cc

    r15806ed r1d17939  
    1010// Created On       : Sun May 17 07:06:19 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Aug 12 10:21:00 2019
    13 // Update Count     : 27
     12// Last Modified On : Wed Jul 29 16:11:00 2020
     13// Update Count     : 28
    1414//
    1515
     
    392392        void ConversionCost::postvisit( const FunctionType * ) {}
    393393
    394         void ConversionCost::postvisit( const StructInstType * inst ) {
    395                 if ( const StructInstType * destAsInst = dynamic_cast< const StructInstType * >( dest ) ) {
    396                         if ( inst->name == destAsInst->name ) {
    397                                 cost = Cost::zero;
    398                         } // if
    399                 } // if
    400         }
    401 
    402         void ConversionCost::postvisit( const UnionInstType * inst ) {
    403                 if ( const UnionInstType * destAsInst = dynamic_cast< const UnionInstType * >( dest ) ) {
    404                         if ( inst->name == destAsInst->name ) {
    405                                 cost = Cost::zero;
    406                         } // if
    407                 } // if
    408         }
    409 
    410394        void ConversionCost::postvisit( const EnumInstType * ) {
    411395                static Type::Qualifiers q;
     
    681665}
    682666
    683 void ConversionCost_new::postvisit( const ast::StructInstType * structInstType ) {
    684         if ( const ast::StructInstType * dstAsInst =
    685                         dynamic_cast< const ast::StructInstType * >( dst ) ) {
    686                 if ( structInstType->name == dstAsInst->name ) {
    687                         cost = Cost::zero;
    688                 }
    689         }
    690 }
    691 
    692 void ConversionCost_new::postvisit( const ast::UnionInstType * unionInstType ) {
    693         if ( const ast::UnionInstType * dstAsInst =
    694                         dynamic_cast< const ast::UnionInstType * >( dst ) ) {
    695                 if ( unionInstType->name == dstAsInst->name ) {
    696                         cost = Cost::zero;
    697                 }
    698         }
    699 }
    700 
    701667void ConversionCost_new::postvisit( const ast::EnumInstType * enumInstType ) {
    702668        (void)enumInstType;
  • src/ResolvExpr/ConversionCost.h

    r15806ed r1d17939  
    1010// Created On       : Sun May 17 09:37:28 2015
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Thu Aug  8 16:13:00 2019
    13 // Update Count     : 6
     12// Last Modified On : Wed Jul 29 16:12:00 2020
     13// Update Count     : 7
    1414//
    1515
     
    5151                void postvisit( const ReferenceType * refType );
    5252                void postvisit( const FunctionType * functionType );
    53                 void postvisit( const StructInstType * aggregateUseType );
    54                 void postvisit( const UnionInstType * aggregateUseType );
    5553                void postvisit( const EnumInstType * aggregateUseType );
    5654                void postvisit( const TraitInstType * aggregateUseType );
     
    102100        void postvisit( const ast::ReferenceType * refType );
    103101        void postvisit( const ast::FunctionType * functionType );
    104         void postvisit( const ast::StructInstType * structInstType );
    105         void postvisit( const ast::UnionInstType * unionInstType );
    106102        void postvisit( const ast::EnumInstType * enumInstType );
    107103        void postvisit( const ast::TraitInstType * traitInstType );
  • tests/.expect/castError.txt

    r15806ed r1d17939  
    1 castError.cfa:21:1 error: Cannot choose between 3 alternatives for expression
     1castError.cfa:23:1 error: Cannot choose between 3 alternatives for expression
    22Explicit Cast of:
    33  Name: f
     
    3535
    3636
    37 castError.cfa:26:1 error: Cannot choose between 2 alternatives for expression
     37castError.cfa:28:1 error: Cannot choose between 2 alternatives for expression
    3838Generated Cast of:
    3939  Comma Expression:
     
    6262
    6363
     64castError.cfa:30:1 error: No reasonable alternatives for expression Explicit Cast of:
     65  Name: sint
     66... to:
     67  instance of struct S with body 1
     68  ... with parameters
     69    char
     70
  • tests/castError.cfa

    r15806ed r1d17939  
    1414//
    1515
     16forall(otype T) struct S { T p; };
    1617int f;
     18S(int) sint;
    1719
    1820void f() {
     
    2527        short int v;
    2628        3, v;           // implicit void cast
     29
     30        (S(char)) sint;
    2731}
    2832
Note: See TracChangeset for help on using the changeset viewer.