Changeset 5809461 for src/SynTree


Ignore:
Timestamp:
Sep 1, 2017, 6:59:48 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:
b0dfbc4
Parents:
bc3127d
Message:

Fix handling of GCC label address and computed goto

Location:
src/SynTree
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/AddressExpr.cc

    rbc3127d r5809461  
    7070}
    7171
     72LabelAddressExpr::LabelAddressExpr( const Label &arg ) : arg( arg ) {
     73        // label address always has type void *
     74        result = new PointerType( Type::Qualifiers(), new VoidType( Type::Qualifiers() ) );
     75}
     76LabelAddressExpr::LabelAddressExpr( const LabelAddressExpr & other ) : Expression( other ), arg( other.arg ) {}
     77LabelAddressExpr::~LabelAddressExpr() {}
     78
     79void LabelAddressExpr::print( std::ostream & os, int indent ) const {
     80        os << "Address of label:" << std::endl << std::string( indent+2, ' ' ) << arg;
     81}
     82
    7283// Local Variables: //
    7384// tab-width: 4 //
  • src/SynTree/Expression.h

    rbc3127d r5809461  
    2424#include "Constant.h"             // for Constant
    2525#include "Initializer.h"          // for Designation (ptr only), Initializer
     26#include "Label.h"                // for Label
    2627#include "Mutator.h"              // for Mutator
    2728#include "SynTree.h"              // for UniqueId
     
    173174};
    174175
    175 // xxx - this doesn't appear to actually be hooked in anywhere. We should use this instead of the "&&"" UntypedExpr hack
     176// GCC &&label
     177// https://gcc.gnu.org/onlinedocs/gcc-3.4.2/gcc/Labels-as-Values.html
    176178class LabelAddressExpr : public Expression {
    177179  public:
    178         Expression * arg;
    179 
    180         LabelAddressExpr( Expression * arg );
     180        Label arg;
     181
     182        LabelAddressExpr( const Label &arg );
    181183        LabelAddressExpr( const LabelAddressExpr & other );
    182184        virtual ~LabelAddressExpr();
    183 
    184         Expression * get_arg() const { return arg; }
    185         void set_arg(Expression * newValue ) { arg = newValue; }
    186185
    187186        virtual LabelAddressExpr * clone() const { return new LabelAddressExpr( * this ); }
  • src/SynTree/Mutator.cc

    rbc3127d r5809461  
    246246        labelAddressExpr->set_env( maybeMutate( labelAddressExpr->get_env(), *this ) );
    247247        labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ) );
    248         labelAddressExpr->set_arg( maybeMutate( labelAddressExpr->get_arg(), *this ) );
    249248        return labelAddressExpr;
    250249}
  • src/SynTree/Visitor.cc

    rbc3127d r5809461  
    205205void Visitor::visit( LabelAddressExpr *labAddressExpr ) {
    206206        maybeAccept( labAddressExpr->get_result(), *this );
    207         maybeAccept( labAddressExpr->get_arg(), *this );
    208207}
    209208
Note: See TracChangeset for help on using the changeset viewer.