diff options
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/eval/addressable-complex.c | 23 | ||||
| -rw-r--r-- | validation/eval/addressable-degen.c | 17 | ||||
| -rw-r--r-- | validation/expand/constant-init-array.c | 15 | ||||
| -rw-r--r-- | validation/expand/constant-init-nested-array.c | 15 | ||||
| -rw-r--r-- | validation/expand/constant-init-nested-struct.c | 23 | ||||
| -rw-r--r-- | validation/expand/constant-init-string.c | 15 | ||||
| -rw-r--r-- | validation/expand/constant-union-flt2int.c | 20 | ||||
| -rw-r--r-- | validation/expand/constant-union-int2flt.c | 19 | ||||
| -rw-r--r-- | validation/expand/constant-union-size.c (renamed from validation/bug-expand-union0.c) | 7 | ||||
| -rw-r--r-- | validation/expand/cost-deref-nested.c | 20 | ||||
| -rw-r--r-- | validation/expand/default-init-array.c | 16 | ||||
| -rw-r--r-- | validation/expand/default-init-struct.c | 22 | ||||
| -rw-r--r-- | validation/expand/union-cast.c | 27 | ||||
| -rw-r--r-- | validation/memops/type-punning-flt2int.c (renamed from validation/bug-expand-union1.c) | 5 | ||||
| -rw-r--r-- | validation/memops/type-punning-int2flt.c | 19 |
15 files changed, 256 insertions, 7 deletions
diff --git a/validation/eval/addressable-complex.c b/validation/eval/addressable-complex.c new file mode 100644 index 00000000..e3d4aca4 --- /dev/null +++ b/validation/eval/addressable-complex.c @@ -0,0 +1,23 @@ +extern void def(void *); + +struct s1 { + int a; +}; + +int use1(void) +{ + struct s1 s = { 3 }; + + def(&s.a); + + return s.a; +} + +/* + * check-name: eval/addressable-complex + * check-command: test-linearize -Wno-decl -fdump-ir $file + * + * check-output-ignore + * check-output-contains: load\\. + * check-output-excludes: return\\..*\\$3 + */ diff --git a/validation/eval/addressable-degen.c b/validation/eval/addressable-degen.c new file mode 100644 index 00000000..d420927e --- /dev/null +++ b/validation/eval/addressable-degen.c @@ -0,0 +1,17 @@ +extern void def(void *, unsigned int); + +static int bar(void) +{ + int x[2] = { 1, 2 }; + + def(x, sizeof(x)); + return x[1]; +} + +/* + * check-name: eval/addressable-degen + * check-command: test-linearize -fdump-ir $file + * + * check-output-ignore + * check-output-contains: load\\. + */ diff --git a/validation/expand/constant-init-array.c b/validation/expand/constant-init-array.c new file mode 100644 index 00000000..94949be5 --- /dev/null +++ b/validation/expand/constant-init-array.c @@ -0,0 +1,15 @@ +int test_array(int i) +{ + static const int a[3] = { 1, 2, 3, }; + + return a[1]; +} + +/* + * check-name: constant-init-array + * check-command: test-linearize -Wno-decl -fdump-ir $file + * + * check-output-ignore + * check-output-excludes: phisrc\\..*return.*\\$2 + * check-output-contains: load\\. + */ diff --git a/validation/expand/constant-init-nested-array.c b/validation/expand/constant-init-nested-array.c new file mode 100644 index 00000000..0d50d955 --- /dev/null +++ b/validation/expand/constant-init-nested-array.c @@ -0,0 +1,15 @@ +int foo(void) +{ + int a[2][3] = {{0, 1, 2},{3, 4, 5}}; + return a[1][2]; +} + +/* + * check-name: constant-init-nested-array + * check-command: test-linearize -Wno-decl -fdump-ir $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: phisrc\\..*\\$5 + * check-output-excludes: load\\. + */ diff --git a/validation/expand/constant-init-nested-struct.c b/validation/expand/constant-init-nested-struct.c new file mode 100644 index 00000000..f27de556 --- /dev/null +++ b/validation/expand/constant-init-nested-struct.c @@ -0,0 +1,23 @@ +struct s { + int a; + struct { + int b; + int c; + } s; +}; + +int foo(void) +{ + struct s s = {1, {2, 3}}; + return s.s.c; +} + +/* + * check-name: constant-init-nested-struct + * check-command: test-linearize -Wno-decl -fdump-ir $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: phisrc\\..*\\$3 + * check-output-excludes: load\\. + */ diff --git a/validation/expand/constant-init-string.c b/validation/expand/constant-init-string.c new file mode 100644 index 00000000..42ae9bd3 --- /dev/null +++ b/validation/expand/constant-init-string.c @@ -0,0 +1,15 @@ +char foo(void) +{ + static const char s[] = "abc?"; + return s[3]; +} + +/* + * check-name: constant-init-nested-array + * check-command: test-linearize -Wno-decl -fdump-ir $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: phisrc\\..*\\$63 + * check-output-pattern(0,1): load\\. + */ diff --git a/validation/expand/constant-union-flt2int.c b/validation/expand/constant-union-flt2int.c new file mode 100644 index 00000000..5e25b592 --- /dev/null +++ b/validation/expand/constant-union-flt2int.c @@ -0,0 +1,20 @@ +union u { + int i; + float f; +}; + +static int foo(void) +{ + union u u = { .f = 0.123 }; + return u.i; +} + +/* + * check-name: constant-union-float-to-int + * check description: must not infer the int value from the float + * check-command: test-linearize -fdump-ir $file + * + * check-output-ignore + * check-output-pattern(1): setfval\\. + * check-output-pattern(1): load\\. + */ diff --git a/validation/expand/constant-union-int2flt.c b/validation/expand/constant-union-int2flt.c new file mode 100644 index 00000000..16ce1c6f --- /dev/null +++ b/validation/expand/constant-union-int2flt.c @@ -0,0 +1,19 @@ +union u { + int i; + float f; +}; + +static float foo(void) +{ + union u u = { .i = 3 }; + return u.f; +} + +/* + * check-name: constant-union-int-to-float + * check description: must not infer the float value from the int + * check-command: test-linearize -fdump-ir $file + * + * check-output-ignore + * check-output-pattern(1): load\\. + */ diff --git a/validation/bug-expand-union0.c b/validation/expand/constant-union-size.c index dd6d60c3..8a16bf3e 100644 --- a/validation/bug-expand-union0.c +++ b/validation/expand/constant-union-size.c @@ -10,10 +10,9 @@ static int foo(void) } /* - * check-name: bug-expand-union - * check description: must not infer the value from the float - * check-command: test-linearize $file - * check-known-to-fail + * check-name: constant-union-size + * check description: the size of the initializer doesn't match + * check-command: test-linearize -fdump-ir $file * * check-output-ignore * check-output-contains: load\\. diff --git a/validation/expand/cost-deref-nested.c b/validation/expand/cost-deref-nested.c new file mode 100644 index 00000000..d6b62396 --- /dev/null +++ b/validation/expand/cost-deref-nested.c @@ -0,0 +1,20 @@ +struct s { + struct { + int u, v; + } a, b; +}; + +static const struct s s; + +static int foo(int c) +{ + return c && s.b.v; +} + +/* + * check-name: cost-deref-nested + * check-command: test-linearize -fdump-ir $file + * + * check-output-ignore + * check-output-excludes: cbr + */ diff --git a/validation/expand/default-init-array.c b/validation/expand/default-init-array.c new file mode 100644 index 00000000..b372ea09 --- /dev/null +++ b/validation/expand/default-init-array.c @@ -0,0 +1,16 @@ +int test_array(int i) +{ + static const int a[3] = { [0] = 1, [2] = 3, }; + + return a[1]; +} + +/* + * check-name: default-init-array + * check-command: test-linearize -Wno-decl -fdump-ir $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: phisrc\\..*return.*\\$0 + * check-output-excludes: load\\. + */ diff --git a/validation/expand/default-init-struct.c b/validation/expand/default-init-struct.c new file mode 100644 index 00000000..085dd2d6 --- /dev/null +++ b/validation/expand/default-init-struct.c @@ -0,0 +1,22 @@ +struct s { + int a; + int b; + int c; +}; + + +int test_struct(void) +{ + struct s s = { .a = 1, .c = 3, }; + + return s.b; +} + +/* + * check-name: default-init-struct + * check-command: test-linearize -Wno-decl -fdump-ir $file + * + * check-output-ignore + * check-output-contains: phisrc\\..*return.*\\$0 + * check-output-excludes: load\\. + */ diff --git a/validation/expand/union-cast.c b/validation/expand/union-cast.c new file mode 100644 index 00000000..a28d01f2 --- /dev/null +++ b/validation/expand/union-cast.c @@ -0,0 +1,27 @@ +union u { + int i; + struct s { + int a; + } s; +}; + +int foo(void) +{ + struct s s = { 3 }; + union u u = (union u)s; + return u.s.a; +} + +/* + * check-name: union-cast + * check-command: test-linearize -Wno-decl -fdump-ir $file + * check-known-to-fail + * + * check-output-ignore + * check-output-excludes: load\\. + * + * check-error-start +union-cast.c:11:22: warning: cast to non-scalar +union-cast.c:11:22: warning: cast from non-scalar + * check-error-end + */ diff --git a/validation/bug-expand-union1.c b/validation/memops/type-punning-flt2int.c index 582a1f4f..fadaf687 100644 --- a/validation/bug-expand-union1.c +++ b/validation/memops/type-punning-flt2int.c @@ -10,10 +10,9 @@ static int foo(void) } /* - * check-name: bug-expand-union - * check description: must not infer the value from the float + * check-name: type-punning-float-to-int + * check description: must not infer the int value from the float * check-command: test-linearize $file - * check-known-to-fail * * check-output-ignore * check-output-contains: load\\. diff --git a/validation/memops/type-punning-int2flt.c b/validation/memops/type-punning-int2flt.c new file mode 100644 index 00000000..061b7423 --- /dev/null +++ b/validation/memops/type-punning-int2flt.c @@ -0,0 +1,19 @@ +union u { + int i; + float f; +}; + +static float foo(void) +{ + union u u = { .i = 3 }; + return u.f; +} + +/* + * check-name: type-punning-int-to-float + * check description: must not infer the float value from the int + * check-command: test-linearize $file + * + * check-output-ignore + * check-output-contains: load\\. + */ |
