Changeset 0982a05


Ignore:
Timestamp:
Aug 30, 2018, 6:30:10 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
Children:
7e08acf, a9fb796, e255e69
Parents:
933933c
Message:

fix 0 and 1 for new for-control

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/parser.yy

    r933933c r0982a05  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 29 16:44:17 2018
    13 // Update Count     : 4006
     12// Last Modified On : Thu Aug 30 17:02:25 2018
     13// Update Count     : 4029
    1414//
    1515
     
    191191
    192192ForCtrl * forCtrl( ExpressionNode * type, string * index, ExpressionNode * start, enum OperKinds compop, ExpressionNode * comp, ExpressionNode * inc ) {
     193        ConstantExpr *constant = dynamic_cast<ConstantExpr *>(type->get_expr());
     194        if ( constant && (constant->get_constant()->get_value() == "0" || constant->get_constant()->get_value() == "1") ) {
     195        type = new ExpressionNode( new CastExpr( maybeMoveBuild< Expression >(type), new BasicType( Type::Qualifiers(), BasicType::SignedInt ) ) );
     196        } // if
    193197        return new ForCtrl(
    194198                distAttr( DeclarationNode::newTypeof( type ), DeclarationNode::newName( index )->addInitializer( new InitializerNode( start ) ) ),
     
    218222
    219223// Types declaration for productions
    220 %union
    221 {
     224%union {
    222225        Token tok;
    223226        ParseNode * pn;
  • tests/.expect/forctrl.txt

    r933933c r0982a05  
    22empty
    33empty
     4
     5A
     6A A
    47A A A A A A A A A A
    58B B B B B
     
    9120 1 2 3 4 5 6 7 8 9
    10130 1 2 3 4 5 6 7 8 9
    11 2 4 6 8 10
     141 3 5 7 9
    121510 8 6 4 2
    13160.5 1.5 2.5 3.5 4.5
  • tests/forctrl.c

    r933933c r0982a05  
    1010// Created On       : Wed Aug  8 18:32:59 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Aug 29 18:04:15 2018
    13 // Update Count     : 26
     12// Last Modified On : Thu Aug 30 17:12:12 2018
     13// Update Count     : 43
    1414//
    1515
     
    3434        for () { sout | "empty"; break; }               sout | endl;
    3535
     36        for ( 0 ) { sout | "A"; }                               sout | endl;
     37        for ( 1 ) { sout | "A"; }                               sout | endl;
     38        for ( 2 ) { sout | "A"; }                               sout | endl;
    3639        for ( 10 ) { sout | "A"; }                              sout | endl;
    3740
    38         for ( 2 ~= 10 ~ 2 ) { sout | "B"; }             sout | endl;
    39         for ( 10 -~= 2 ~ -2 ) { sout | "C"; }   sout | endl;
     41        for ( 1 ~= 10 ~ 2 ) { sout | "B"; }             sout | endl;
     42        for ( 10 -~= 1 ~ -2 ) { sout | "C"; }   sout | endl;
    4043        for ( 0.5 ~ 5.5 ) { sout | "D"; }               sout | endl;
    4144        for ( 5.5 -~ 0.5 ) { sout | "E"; }              sout | endl;
     
    4447        for ( j; 10 ) { sout | j; }                             sout | endl;
    4548
    46         //for ( i; 1 ~= 10 ~ 2 ) { sout | i; }  sout | endl;
    47         for ( i; 2 ~= 10 ~ 2 ) { sout | i; }    sout | endl;
    48         for ( i; 10 -~= 2 ~ -2 ) { sout | i; }  sout | endl;
     49        for ( i; 1 ~= 10 ~ 2 ) { sout | i; }    sout | endl;
     50        for ( i; 10 -~= 1 ~ -2 ) { sout | i; }  sout | endl;
    4951        for ( i; 0.5 ~ 5.5 ) { sout | i; }              sout | endl;
    5052        for ( i; 5.5 -~ 0.5 ) { sout | i; }             sout | endl;
Note: See TracChangeset for help on using the changeset viewer.