Changeset b0440b7 for src/SynTree


Ignore:
Timestamp:
Aug 8, 2017, 8:01:10 PM (7 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:
9a4e996
Parents:
4618319
Message:

Prevent reference types from being added in Box through createDeref

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Expression.cc

    r4618319 rb0440b7  
    3434#include "InitTweak/InitTweak.h"
    3535
     36#include "GenPoly/Lvalue.h"
    3637
    3738Expression::Expression( Expression *_aname ) : result( 0 ), env( 0 ), argName( _aname ) {}
     
    409410                Type * base = InitTweak::getPointerBase( type );
    410411                assertf( base, "expected pointer type in dereference (type was %s)", toString( type ).c_str() );
    411                 ret->set_result( new ReferenceType( Type::Qualifiers(), base->clone() ) );
     412                ret->set_result( base->clone() );
     413                if ( GenPoly::referencesPermissable() ) {
     414                        // if references are still allowed in the AST, dereference returns a reference
     415                        ret->set_result( new ReferenceType( Type::Qualifiers(), ret->get_result() ) );
     416                } else {
     417                        // references have been removed, in which case dereference returns an lvalue of the base type.
     418                        ret->get_result()->set_lvalue( true );
     419                }
    412420        }
    413421        return ret;
Note: See TracChangeset for help on using the changeset viewer.