Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/frontc/cabs2cil.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4031,8 +4031,17 @@ and doExp (asconst: bool) (* This expression is used as a constant *)
else
E.s (error "Unary ~ on a non-integral type")

| A.UNARY(A.PLUS, e) -> doExp asconst e what

| A.UNARY(A.PLUS, e) ->
let (se, e', t) = doExp asconst e (AExp None) in
if isIntegralType t then
let tres = integralPromotion t in
let e'' = makeCastT ~kind:IntegerPromotion ~e:e' ~oldt:t ~newt:tres in
finishExp se e'' tres
else
if isArithmeticType t then
finishExp se e' t
else
E.s (error "Unary + on a non-arithmetic type")

| A.UNARY(A.ADDROF, e) -> begin
match e with
Expand Down
13 changes: 13 additions & 0 deletions test/small1/unary-plus-promotion.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "testharness.h"
#include <stdlib.h>

int main() {
char c;
size_t csize = sizeof(c);
size_t pluscsize = sizeof(+c);
if (csize != sizeof(char))
E(1);
if (pluscsize != sizeof(int))
E(2);
SUCCESS;
}
1 change: 1 addition & 0 deletions test/testcil.pl
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ sub addToGroup {
addTest("test_i/lineno");
addTest("test/list");
addTest("testrun/localinit ");
addTest("testrun/unary-plus-promotion");

addTest('testrun/longBlock', '');
addTest("testrun/perror");
Expand Down
Loading