Changeset 7b1d5ec


Ignore:
Timestamp:
Sep 11, 2017, 5:13:36 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
6de9f4a
Parents:
15697ff
Message:

add cast for designated (hh or h) unsigned char and short literals to get correct behaviour

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/ExpressionNode.cc

    r15697ff r7b1d5ec  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Sep 10 09:56:06 2017
    13 // Update Count     : 655
     12// Last Modified On : Mon Sep 11 16:06:42 2017
     13// Update Count     : 666
    1414//
    1515
     
    167167
    168168        ret = new ConstantExpr( Constant( new BasicType( noQualifiers, kind[Unsigned][size] ), str, v ) );
     169        if ( Unsigned && size < 2 ) {                                           // less than int ?
     170                // int i = -1uh => 65535 not -1, so cast is necessary for unsigned, which eliminates some warnings for large
     171                // values.
     172                ret = new CastExpr( ret, new BasicType( Type::Qualifiers(), kind[Unsigned][size] ) );
     173        } // if
    169174  CLEANUP:
    170175        if ( units.length() != 0 ) {
Note: See TracChangeset for help on using the changeset viewer.