diff options
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/call-inlined.c | 4 | ||||
| -rw-r--r-- | validation/eval/unqual-cast.c | 14 | ||||
| -rw-r--r-- | validation/eval/unqual-comma.c | 12 | ||||
| -rw-r--r-- | validation/eval/unqual-postop.c | 23 | ||||
| -rw-r--r-- | validation/eval/unqual-stmt-expr.c | 12 | ||||
| -rw-r--r-- | validation/eval/unqual02.c | 26 | ||||
| -rw-r--r-- | validation/expand/builtin_constant_inline0.c | 1 | ||||
| -rw-r--r-- | validation/inline_base0.c | 3 | ||||
| -rw-r--r-- | validation/linear/builtin_unreachable0.c | 4 | ||||
| -rw-r--r-- | validation/linear/builtin_unreachable1.c | 4 | ||||
| -rw-r--r-- | validation/linear/call-inline.c | 2 | ||||
| -rw-r--r-- | validation/mem2reg/cond-expr.c | 4 | ||||
| -rw-r--r-- | validation/mem2reg/cond-expr5.c | 5 | ||||
| -rw-r--r-- | validation/optim/cse-size.c | 5 | ||||
| -rw-r--r-- | validation/optim/memops-missed01.c | 23 | ||||
| -rw-r--r-- | validation/optim/memops-missed02.c | 14 | ||||
| -rw-r--r-- | validation/optim/merge_bbe-adjust_phi.c | 23 |
17 files changed, 167 insertions, 12 deletions
diff --git a/validation/call-inlined.c b/validation/call-inlined.c index 3612c5c4..a6cb4b5b 100644 --- a/validation/call-inlined.c +++ b/validation/call-inlined.c @@ -28,12 +28,14 @@ foo: <entry-point> add.32 %r3 <- %arg1, %arg2 add.32 %r5 <- %r3, $1 + # call %r6 <- add, %r3, $1 ret.32 %r5 bar: .L3: <entry-point> + # call %r13 <- add, %r10, $1 ret @@ -41,6 +43,7 @@ bas: .L6: <entry-point> add.64 %r16 <- "abc", $1 + # call %r17 <- lstrip, %r14 ret.64 %r16 @@ -48,6 +51,7 @@ qus: .L9: <entry-point> add.64 %r21 <- messg, $1 + # call %r22 <- lstrip, %r19 ret.64 %r21 diff --git a/validation/eval/unqual-cast.c b/validation/eval/unqual-cast.c new file mode 100644 index 00000000..4106ec3b --- /dev/null +++ b/validation/eval/unqual-cast.c @@ -0,0 +1,14 @@ +#define cvr const volatile restrict + +_Static_assert([typeof((cvr int) 0)] == [int]); +_Static_assert([typeof((cvr int *) 0)] == [cvr int *]); + +static int *function(volatile int x) +{ + extern typeof((typeof(x)) (x)) y; + return &y; +} + +/* + * check-name: unqual-cast + */ diff --git a/validation/eval/unqual-comma.c b/validation/eval/unqual-comma.c new file mode 100644 index 00000000..11546d22 --- /dev/null +++ b/validation/eval/unqual-comma.c @@ -0,0 +1,12 @@ +#define __unqual_typeof(x) typeof(((void)0, (x))) + +int *foo(volatile int x); +int *foo(volatile int x) +{ + extern __unqual_typeof(x) y; + return &y; +} + +/* + * check-name: unqual-comma + */ diff --git a/validation/eval/unqual-postop.c b/validation/eval/unqual-postop.c new file mode 100644 index 00000000..fb3082dc --- /dev/null +++ b/validation/eval/unqual-postop.c @@ -0,0 +1,23 @@ +static void test_volatile(void) +{ + volatile int x = 0; + int *pp; + + typeof(++x) v1; pp = &v1; // KO + typeof(x++) v2; pp = &v2; // KO +} + +/* + * check-name: unqual-postop + * check-command: sparse -Wno-declaration-after-statement $file + * check-known-to-fail + * + * check-error-start +eval/unqual-postop.c:6:40: warning: incorrect type in assignment (different modifiers) +eval/unqual-postop.c:6:40: expected int *pp +eval/unqual-postop.c:6:40: got int volatile * +eval/unqual-postop.c:7:40: warning: incorrect type in assignment (different modifiers) +eval/unqual-postop.c:7:40: expected int *pp +eval/unqual-postop.c:7:40: got int volatile * + * check-error-end + */ diff --git a/validation/eval/unqual-stmt-expr.c b/validation/eval/unqual-stmt-expr.c new file mode 100644 index 00000000..280c2fe8 --- /dev/null +++ b/validation/eval/unqual-stmt-expr.c @@ -0,0 +1,12 @@ +#define __unqual_typeof(x) typeof(({ x; })) + +int *foo(volatile int x); +int *foo(volatile int x) +{ + extern __unqual_typeof(x) y; + return &y; +} + +/* + * check-name: unqual-stmt-expr + */ diff --git a/validation/eval/unqual02.c b/validation/eval/unqual02.c new file mode 100644 index 00000000..f136cbd5 --- /dev/null +++ b/validation/eval/unqual02.c @@ -0,0 +1,26 @@ +static void test_const(volatile int x) +{ + const int x = 0; + typeof(1?x:x) i3; i3 = 0; // should be OK + typeof(+x) i4; i4 = 0; // should be OK + typeof(-x) i5; i5 = 0; // should be OK + typeof(!x) i6; i6 = 0; // should be OK + typeof(x+x) i7; i7 = 0; // should be OK +} + +static void test_volatile(void) +{ + volatile int x = 0; + int *pp; + + typeof(1?x:x) i3; pp = &i3; // should be OK + typeof(+x) i4; pp = &i4; // should be OK + typeof(-x) i5; pp = &i5; // should be OK + typeof(!x) i6; pp = &i6; // should be OK + typeof(x+x) i7; pp = &i7; // should be OK +} + +/* + * check-name: unqual02 + * check-command: sparse -Wno-declaration-after-statement $file + */ diff --git a/validation/expand/builtin_constant_inline0.c b/validation/expand/builtin_constant_inline0.c index a0057f20..d72a211f 100644 --- a/validation/expand/builtin_constant_inline0.c +++ b/validation/expand/builtin_constant_inline0.c @@ -16,6 +16,7 @@ int foo(void) foo: .L0: <entry-point> + # call %r1 <- is_const, $42 ret.32 $42 diff --git a/validation/inline_base0.c b/validation/inline_base0.c index 517ee972..698c760f 100644 --- a/validation/inline_base0.c +++ b/validation/inline_base0.c @@ -27,6 +27,7 @@ foo0: .L0: <entry-point> add.32 %r5 <- %arg1, %arg2 + # call %r6 <- add, %r1, %r2 ret.32 %r5 @@ -34,12 +35,14 @@ foo1: .L3: <entry-point> add.32 %r10 <- %arg1, $1 + # call %r11 <- add, %r8, $1 ret.32 %r10 foo2: .L6: <entry-point> + # call %r13 <- add, $1, $2 ret.32 $3 diff --git a/validation/linear/builtin_unreachable0.c b/validation/linear/builtin_unreachable0.c index 911ed7f9..4fc56473 100644 --- a/validation/linear/builtin_unreachable0.c +++ b/validation/linear/builtin_unreachable0.c @@ -14,12 +14,12 @@ foo: .L0: <entry-point> seteq.32 %r2 <- %arg1, $3 - cbr %r2, .L1, .L3 + cbr %r2, .L1, .L2 .L1: unreachable -.L3: +.L2: ret.32 %arg1 diff --git a/validation/linear/builtin_unreachable1.c b/validation/linear/builtin_unreachable1.c index 70f6674c..2fc1d728 100644 --- a/validation/linear/builtin_unreachable1.c +++ b/validation/linear/builtin_unreachable1.c @@ -16,9 +16,9 @@ int foo(int c) foo: .L0: <entry-point> - cbr %arg1, .L3, .L2 + cbr %arg1, .L1, .L2 -.L3: +.L1: ret.32 $1 .L2: diff --git a/validation/linear/call-inline.c b/validation/linear/call-inline.c index dfd49b62..1ad785ee 100644 --- a/validation/linear/call-inline.c +++ b/validation/linear/call-inline.c @@ -13,6 +13,6 @@ int i3(void) { return (***fun)(); } // C99,C11 6.5.3.2p4 * * check-output-ignore * check-output-excludes: load - * check-output-excludes: call + * check-output-excludes: \\tcall * check-output-pattern(5): ret\\..* \\$42 */ diff --git a/validation/mem2reg/cond-expr.c b/validation/mem2reg/cond-expr.c index 8acb00ac..2474d65d 100644 --- a/validation/mem2reg/cond-expr.c +++ b/validation/mem2reg/cond-expr.c @@ -9,6 +9,6 @@ int foo(int a, int b, int c) * check-name: cond-expr * check-command: test-linearize -Wno-decl -fdump-ir=mem2reg $file * check-output-ignore - * check-output-pattern(2): phi\\. - * check-output-pattern(3): phisrc\\. + * check-output-pattern(1): phi\\. + * check-output-pattern(2): phisrc\\. */ diff --git a/validation/mem2reg/cond-expr5.c b/validation/mem2reg/cond-expr5.c index a3ce5e3a..beef8f25 100644 --- a/validation/mem2reg/cond-expr5.c +++ b/validation/mem2reg/cond-expr5.c @@ -15,7 +15,6 @@ int foo(int p, int q, int a) * check-output-ignore * check-output-excludes: load\\. * check-output-excludes: store\\. - * check-output-excludes: phi\\..*, .*, .* - * check-output-pattern(3): phi\\. - * check-output-pattern(5): phisrc\\. + * check-output-pattern(2): phi\\. + * check-output-pattern(4): phisrc\\. */ diff --git a/validation/optim/cse-size.c b/validation/optim/cse-size.c index 5b31420c..0c0c2d14 100644 --- a/validation/optim/cse-size.c +++ b/validation/optim/cse-size.c @@ -1,7 +1,7 @@ static void foo(void) { unsigned short p = 0; - int x; + int x = 1; for (;;) if (p) @@ -13,5 +13,6 @@ static void foo(void) * check-command: test-linearize -Wno-decl $file * * check-output-ignore - * check-output-pattern(2): phi\\. + * check-output-excludes: phi\\. + * check-output-excludes: cbr */ diff --git a/validation/optim/memops-missed01.c b/validation/optim/memops-missed01.c new file mode 100644 index 00000000..fc616f19 --- /dev/null +++ b/validation/optim/memops-missed01.c @@ -0,0 +1,23 @@ +void bar(int); + +void foo(void) +{ + char buf[1] = { 42 }; + const char *p = buf; + const char **q = &p; + int ch = 0; + switch (**q) { + case 4: + ch = 2; + } + bar(ch); +} + +/* + * check-name: memops-missed01 + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-excludes: store\\. + * check-output-excludes: load\\. + */ diff --git a/validation/optim/memops-missed02.c b/validation/optim/memops-missed02.c new file mode 100644 index 00000000..6f028649 --- /dev/null +++ b/validation/optim/memops-missed02.c @@ -0,0 +1,14 @@ +void foo(int a[]) +{ + int i, val; + for (;; i++) + val = a[i] ? a[i] : val; +} + +/* + * check-name: memops-missed02 + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-pattern(1): load\\. + */ diff --git a/validation/optim/merge_bbe-adjust_phi.c b/validation/optim/merge_bbe-adjust_phi.c new file mode 100644 index 00000000..6a8ebb73 --- /dev/null +++ b/validation/optim/merge_bbe-adjust_phi.c @@ -0,0 +1,23 @@ +extern int array[2]; + +static inline int stupid_select(int idx) +{ + if (idx) + idx = 0; + return array[idx]; +} + +int select(void) +{ + int d = stupid_select(-1); + return d; +} + +/* + * check-name: merge_bbe-adjust_phi + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-excludes: phisrc\\. + * check-output-excludes: phi\\. + */ |
