diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-12-06 04:36:21 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-12-10 23:26:23 +0100 |
commit | 391bd454457e496410f92b1c730a48b277f460e4 (patch) | |
tree | 4dac281215fb82bf4e7deaf5ad10628167ee6faf | |
parent | 613a671f31d2a44aa2e04ce05b77d1daad972f20 (diff) | |
download | sparse-391bd454457e496410f92b1c730a48b277f460e4.tar.gz |
add test for union cast
Sparse can't do this yet.
So, add a testcase for it.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | validation/expand/union-cast.c | 27 |
1 files changed, 27 insertions, 0 deletions
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 + */ |