File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4031,8 +4031,17 @@ and doExp (asconst: bool) (* This expression is used as a constant *)
40314031 else
40324032 E. s (error " Unary ~ on a non-integral type" )
40334033
4034- | A. UNARY (A. PLUS, e ) -> doExp asconst e what
4035-
4034+ | A. UNARY (A. PLUS, e ) ->
4035+ let (se, e', t) = doExp asconst e (AExp None ) in
4036+ if isIntegralType t then
4037+ let tres = integralPromotion t in
4038+ let e'' = makeCastT ~kind: IntegerPromotion ~e: e' ~oldt: t ~newt: tres in
4039+ finishExp se e'' tres
4040+ else
4041+ if isArithmeticType t then
4042+ finishExp se e' t
4043+ else
4044+ E. s (error " Unary + on a non-arithmetic type" )
40364045
40374046 | A. UNARY (A. ADDROF, e ) -> begin
40384047 match e with
Original file line number Diff line number Diff line change 1+ #include "testharness.h"
2+ #include <stdlib.h>
3+
4+ int main () {
5+ char c ;
6+ size_t csize = sizeof (c );
7+ size_t pluscsize = sizeof (+ c );
8+ if (csize != sizeof (char ))
9+ E (1 );
10+ if (pluscsize != sizeof (int ))
11+ E (2 );
12+ SUCCESS ;
13+ }
Original file line number Diff line number Diff line change @@ -323,6 +323,7 @@ sub addToGroup {
323323addTest(" test_i/lineno" );
324324addTest(" test/list" );
325325addTest(" testrun/localinit " );
326+ addTest(" testrun/unary-plus-promotion" );
326327
327328addTest(' testrun/longBlock' , ' ' );
328329addTest(" testrun/perror" );
You can’t perform that action at this time.
0 commit comments