Skip to content

Commit 597cbec

Browse files
authored
Merge pull request #205 from jprotopopov-ut/attr-param-mult-1
Add multiplication support to attribute parameter evaluation
2 parents e21285a + 597f036 commit 597cbec

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/cil.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2358,6 +2358,7 @@ and intOfAttrparam (a:attrparam) : int option =
23582358
match a with
23592359
AInt(n) -> n
23602360
| ABinOp(Shiftlt, a1, a2) -> (doit a1) lsl (doit a2)
2361+
| ABinOp(Mult, a1, a2) -> (doit a1) * (doit a2)
23612362
| ABinOp(Div, a1, a2) -> (doit a1) / (doit a2)
23622363
| ASizeOf(t) ->
23632364
let bs = bitsSizeOf t in

test/small1/attr-multiplication.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
struct S1 {
2+
char a;
3+
} __attribute__((aligned(sizeof(short) * sizeof(int))));
4+
5+
6+
struct S2 {
7+
int x: __builtin_choose_expr(__alignof__ (struct S1) == sizeof(short) * sizeof(int), 1, -1);
8+
} s2;

test/testcil.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ sub addToGroup {
225225
addTest("test/attr11 _GNUCC=1");
226226
addTest("test/attr12 _GNUCC=1");
227227
addTest("test/attr13 _GNUCC=1");
228+
addTest("test/attr-multiplication");
228229
# addTest("test/attr-assign"); # TODO: only on OSX, Linux GCC errors on introduced
229230
# addTest("test/attr-enumerator"); # TODO: only on OSX, Linux GCC errors on introduced
230231
addTest("testrun/packed _GNUCC=1 WARNINGS_ARE_ERRORS=1");

0 commit comments

Comments
 (0)